Artifact
63fda48ccd9101b08a3308cc5c5175e321967b0156b8ec53234f065b97b7fff9:
Wiki page
[tools] by
alex
2018-08-25 20:16:36.
D 2018-08-25T20:16:36.294
L tools
P f93ef9ab273cbd3e5550e3715f8942bfdd26dee35b0dd3ea828da5ca15dc7d3b
U alex
W 2273
<h3>demo.xml</h3>
<verbatim><?xml version="1.0" encoding="UTF-8"?>
<Demo>
<!--comment block goes here-->
<Node attribute="value">
<SubNode>text data</SubNode>
</Node>
<?piTag the processing instructions goes here?>
<Node><![CDATA[</this is malformed!</malformed</malformed & worse cDATA>]]></Node>
</Demo></verbatim>
<hr>
<h3>xmltotdom.tcl <file></h3>
<p>Will create a tcl source code to build a xml file as the original.<br>Example of demo.xml:</p>
<verbatim>package require tdom 0.9.0-
set encoding utf-8
set doc [dom createDocument Demo]
set root [$doc documentElement]
$root appendChild [$doc createComment {comment block goes here}]
$root appendChild [set node0 [$doc createElement Node]]
$node0 setAttribute attribute value
$node0 appendChild [set node1 [$doc createElement SubNode]]
$node1 appendChild [$doc createTextNode {text data}]
$root appendChild [$doc createProcessingInstruction piTag {the processing instructions goes here}]
$root appendChild [set node0 [$doc createElement Node]]
$node0 appendChild [$doc createCDATASection {</this is malformed!</malformed</malformed & worse cDATA>}]
fconfigure stdout -encoding $encoding
puts [$root asXML -indent 2 -xmlDeclaration 1 -encString [string toupper $encoding]]</verbatim>
<hr>
<h3>xmltotdomnodecmd.tcl <file></h3>
<p>Will create a tcl source code using nodecmd to build a xml file as the original.<br>Example of demo.xml:</p>
<verbatim>package require tdom 0.9.0-
set encoding utf-8
dom createNodeCmd cdataNode CData
dom createNodeCmd commentNode Comment
dom createNodeCmd piNode PInstr
dom createNodeCmd textNode Text
dom createNodeCmd -tagName Node elementNode Tag_Node
dom createNodeCmd -tagName SubNode elementNode Tag_SubNode
set doc [dom createDocument Demo]
set root [$doc documentElement]
$root appendFromScript {
Comment {comment block goes here}
Tag_Node attribute value {
Tag_SubNode {
Text text data
}
}
PInstr piTag {the processing instructions goes here}
Tag_Node {
CData {</this is malformed!</malformed</malformed & worse cDATA>}
}
}
fconfigure stdout -encoding $encoding
puts [$root asXML -indent 2 -xmlDeclaration 1 -encString [string toupper $encoding]]</verbatim>
Z 79151f1575d7e95a605b0783499373f2