NAME

dom   -   Create an in-memory DOM tree from XML

SYNOPSIS

dom option  ?arg arg ...

DESCRIPTION

This command provides the creation of complete DOM trees in memory. In the usual case a string containing a XML information is parsed and converted into a DOM tree. option indicates a specific subcommand. The valid options are:

dom parse  ?-simple?   ?-keepEmptiesxml  ?objVar
Parses the XML information and builds up the DOM tree in memory providing a Tcl object command to this DOM document object. Example:

dom parse $xml doc
$doc documentElement root
      
parses the XML in the variable xml, creates the DOM tree in memory, make a reference to the document object, visible in Tcl as a document object command, and assigns this new object name to the variable doc. When doc gets freed, the DOM tree and the associated Tcl command object (document and all node objects) are freed automatically.

set document [dom parse $xml]
set root     [$document documentElement]
      
parses the XML in the variable xml, creates the DOM tree in memory, make a reference to the document object, visible in Tcl as a document object command, and returns this new object name, which is then stored in document. To free the underlying DOM tree and the associative Tcl object commands (document + nodes + fragment nodes) the document object command has to be explicitly deleted by:

$document delete
or
rename $document ""
      
If -simple is specified, a simple but fast parser is used (conforms not fully to XML recommendation). That should double parsing and DOM generation speed. UTF-8 is not generated internally with that parser.

If -keepEmpties is specified, text nodes, which contain only whitespaces, will be part of the resulting DOM tree. In default case (-keepEmpties not given) those empty text nodes are removed at parsing time.

dom createDocument docElemName  ?objVar
Creates a new DOM document object with one element node with node name docElemName. The objVar controlls the memory handling as explained above.

dom setResultEncoding  ?encodingName
If encodingName is not given the current global result encoding is returned. Otherwise the global result encoding is set to encodingName. All character data, attribute values, etc. will then be converted from UTF-8, which is delivered from the Expat XML parser, to the given 8 bit encoding at XML/DOM parse time. Valid values for encodingName are: utf-8, ascii, cp1250, cp1251, cp1252, cp1253, cp1254, cp1255, cp1256, cp437, cp850, en, iso8859-1, iso8859-2, iso8859-3, iso8859-4, iso8859-5, iso8859-6, iso8859-7, iso8859-8, iso8859-9, koi8-r.
Otherwise, if an unknown method name is given, the command with the same name as the given metho within the namespace ::dom::DOMImplementation is tried to be executed. This allows quick method additions on Tcl level.

PORTABILITY ISSUES

SEE ALSO

 
domNode,  domDoc