<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 & worse cDATA>]]></Node>


<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 & 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 & worse cDATA>}
  }
}
fconfigure stdout -encoding $encoding
puts [$root asXML -indent 2 -xmlDeclaration 1 -encString [string toupper $encoding]]</verbatim>