NAME
dom - Create an in-memory DOM tree from XML
SYNOPSIS
package require tdom
ddoomm method ?arg arg ...?DESCRIPTION
This command provides the creation of complete DOM trees in memory. Inthe usual case a string containing a XML information is parsed and con-
verted into a DOM tree. method indicates a specific subcommand. The valid methods are: ddoomm ppaarrssee ??options?? ??data?? 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 mem-
ory, 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 mem-
ory, 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
orrename $document ""
The valid options are:-ssiimmppllee
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. The encoding of the data is not transformed inside the parser. The simple parser does not respect any encoding information in the XML declaration. It skips over the internal DTD subset and ignores any information in it. Therefor it doesn't include defaulted attribute values into the tree, even if the according attribute declaration is in the internal subset. It also doesn't expand internal or external entity references other than the predefined entities and character references.-hhttmmll If -html is specified, a fast HTML parser is used, which
tries to even parse badly formed HTML into a DOM tree.-kkeeeeppEEmmppttiieess
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.-cchhaannnneell
If -channel
parsed is read from the specified channel. The encodingis specified, the input to be setting of the channel (via fconfigure -encoding) is
respected, ie the data read from the channel are con-
verted to UTF-8 according to the encoding settings, befor
the data is parsed.-bbaasseeuurrll
If -baseurl
is specified, the baseURI is used as the base URI of the document. External entities refer-
enced in the document are resolved relative to this base URI. This base URI is also stored within the DOM tree.-ffeeeeddbbaacckkAAfftteerr <#bytes>
If -feedbackAfter <#bytes> is specified, the tcl command
::dom::domParseFeedback is evaluated after parsing every
#bytes. If you use this option, you have to create a tcl
proc named ::dom::domParseFeedback, otherwise you will
get an error. Please notice, that the calls of::dom::domParseFeedback are not done exactly every
#bytes, but always at the first element start after every
#bytes.
-eexxtteerrnnaalleennttiittyyccoommmmaanndd