summaryrefslogtreecommitdiffstats
path: root/tcldom-libxml2.tcl
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2019-01-03 16:54:16 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2019-01-03 16:54:16 (GMT)
commitc0573da8973e0ae8650d787d639a9acf9ab4a1ac (patch)
treeae0daad36caaacde226aa18a75415b247b89148b /tcldom-libxml2.tcl
downloadblt-c0573da8973e0ae8650d787d639a9acf9ab4a1ac.zip
blt-c0573da8973e0ae8650d787d639a9acf9ab4a1ac.tar.gz
blt-c0573da8973e0ae8650d787d639a9acf9ab4a1ac.tar.bz2
Squashed 'tclxml/' content from commit 22ffbb5a
git-subtree-dir: tclxml git-subtree-split: 22ffbb5a3e984efb993e8b58cdf7a11ffddd1836
Diffstat (limited to 'tcldom-libxml2.tcl')
-rw-r--r--tcldom-libxml2.tcl37
1 files changed, 37 insertions, 0 deletions
diff --git a/tcldom-libxml2.tcl b/tcldom-libxml2.tcl
new file mode 100644
index 0000000..d5ef415
--- /dev/null
+++ b/tcldom-libxml2.tcl
@@ -0,0 +1,37 @@
+# impl.tcl --
+#
+# Support script for libxml2 implementation.
+#
+# Std disclaimer
+#
+# $Id: tcldom-libxml2.tcl,v 1.1.1.1 2009/01/16 22:11:49 joye Exp $
+
+namespace eval ::dom {
+ variable strictDOM 1
+}
+
+proc dom::libxml2::parse {xml args} {
+
+ array set options {
+ -keep normal
+ -retainpath /*
+ }
+ array set options $args
+
+ if {[catch {eval ::xml::parser -parser libxml2 [array get options]} parser]} {
+ return -code error "unable to create XML parser due to \"$parser\""
+ }
+
+ if {[catch {$parser parse $xml} msg]} {
+ return -code error $msg
+ }
+
+ set doc [$parser get document]
+ set dom [dom::libxml2::adoptdocument $doc]
+ $parser free
+
+ return $dom
+}
+proc dom::parse {xml args} {
+ return [eval ::dom::libxml2::parse [list $xml] $args]
+}