ooxml

tools
Login

tools

demo.xml

<?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>

xmltotdom.tcl <file>

Will create a tcl source code to build a xml file as the original.
Example of demo.xml:

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]]

xmltotdomnodecmd.tcl <file>

Will create a tcl source code using nodecmd to build a xml file as the original.
Example of demo.xml:

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]]