summaryrefslogtreecommitdiffstats
path: root/tclxml/tcldom-libxml2.tcl
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2019-01-02 20:21:27 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2019-01-02 20:21:27 (GMT)
commit62d64d9d13ee541e11854265c2817e540f50b59a (patch)
tree0b07fb95ebdc8de3e700226b1210a34c98759748 /tclxml/tcldom-libxml2.tcl
parent8f5c6286538d2f0c762edeacf21f85eeeed1fe0b (diff)
parent73444843b18bba4a07922722b11ac3a7fe32a11b (diff)
downloadblt-62d64d9d13ee541e11854265c2817e540f50b59a.zip
blt-62d64d9d13ee541e11854265c2817e540f50b59a.tar.gz
blt-62d64d9d13ee541e11854265c2817e540f50b59a.tar.bz2
Merge commit '73444843b18bba4a07922722b11ac3a7fe32a11b' as 'tclxml'
Diffstat (limited to 'tclxml/tcldom-libxml2.tcl')
-rw-r--r--tclxml/tcldom-libxml2.tcl37
1 files changed, 37 insertions, 0 deletions
diff --git a/tclxml/tcldom-libxml2.tcl b/tclxml/tcldom-libxml2.tcl
new file mode 100644
index 0000000..d5ef415
--- /dev/null
+++ b/tclxml/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]
+}