The TQDomDocument class represents the entire XML document. Conceptually, it is the root of the document tree, and provides the primary access to the document's data.
Since elements, text nodes, comments, processing instructions, etc., cannot exist outside the context of a document, the document class also contains the factory functions needed to create these objects. The node objects created have an ownerDocument() function which associates them with the document within whose context they were created. The DOM classes that will be used most often are TQDomNode, TQDomDocument, TQDomElement and TQDomText.
The parsed XML is represented internally by a tree of objects that can be accessed using the various TQDom classes. All TQDom classes only \fIreference\fR objects in the internal tree. The internal objects in the DOM tree will get deleted once the last TQDom object referencing them and the TQDomDocument itself are deleted.
Creation of elements, text nodes, etc. is done using the various factory functions provided in this class. Using the default constructors of the TQDom classes will only result in empty objects that cannot be manipulated or inserted into the Document.
The TQDomDocument class has several functions for creating document data, for example, createElement(), createTextNode(), createComment(), createCDATASection(), createProcessingInstruction(), createAttribute() and createEntityReference(). Some of these functions have versions that support namespaces, i.e. createElementNS() and createAttributeNS(). The createDocumentFragment() function is used to hold parts of the document; this is useful for manipulating for complex documents.
The entire content of the document is set with setContent(). This function parses the string it is passed as an XML document and creates the DOM tree that represents the document. The root element is available using documentElement(). The textual representation of the document can be obtained using toString().
.PP
It is possible to insert a node from another document into the document using importNode().
.PP
You can obtain a list of all the elements that have a particular tag with elementsByTagName() or with elementsByTagNameNS().
For further information about the Document Object Model see http://www.w3.org/TR/REC-DOM-Level-1/ and http://www.w3.org/TR/DOM-Level-2-Core/. For a more general introduction of the DOM implementation see the TQDomDocument documentation.
Creates a new attribute with namespace support that can be inserted into an element. The name of the attribute is \fIqName\fR and the namespace URI is \fInsURI\fR. This function also sets TQDomNode::prefix() and TQDomNode::localName() to appropriate values (depending on \fIqName\fR).
Creates a new element with namespace support that can be inserted into the DOM tree. The name of the element is \fIqName\fR and the namespace URI is \fInsURI\fR. This function also sets TQDomNode::prefix() and TQDomNode::localName() to appropriate values (depending on \fIqName\fR).
Creates a new processing instruction that can be inserted into the document, e.g. using TQDomNode::appendChild(). This function sets the target for the processing instruction to \fItarget\fR and the data to \fIdata\fR.
This rule also applies to characters encoded as character entities and characters in CDATA sections. If you use this function to insert characters outside of this range, the document will not be well-formed.
.PP
If you want to store binary data in an XML document you must either use your own scheme to escape illegal characters, or you must store it in an external unparsed entity.
Returns a TQDomNodeList, that contains all the elements in the document with the name \fItagname\fR. The order of the node list is the order they are encountered in a preorder traversal of the element tree.
Returns a TQDomNodeList that contains all the elements in the document with the local name \fIlocalName\fR and a namespace URI of \fInsURI\fR. The order of the node list is the order they are encountered in a preorder traversal of the element tree.
Imports the node \fIimportedNode\fR from another document to this document. \fIimportedNode\fR remains in the original document; this function creates a copy that can be used within this document.
This function returns the imported node that belongs to this document. The returned node has no parent. It is not possible to import TQDomDocument and TQDomDocumentType nodes. In those cases this function returns a null node.
If \fIdeep\fR is TRUE, this function imports not only the node \fIimportedNode\fR but its whole subtree; if it is FALSE, only the \fIimportedNode\fR is imported. The argument \fIdeep\fR has no effect on TQDomAttr and TQDomEntityReference nodes, since the descendents of TQDomAttr nodes are always imported and those of TQDomEntityReference nodes are never imported.
l - l. Node Type Behaviour TQDomAttr The owner element is set to 0 and the specified flag is set to TRUE in the generated attribute. The whole subtree of \fIimportedNode\fR is always imported for attribute nodes: \fIdeep\fR has no effect. TQDomDocument Document nodes cannot be imported. TQDomDocumentFragment If \fIdeep\fR is TRUE, this function imports the whole document fragment; otherwise it only generates an empty document fragment. TQDomDocumentType Document type nodes cannot be imported. TQDomElement Attributes for which TQDomAttr::specified() is TRUE are also imported, other attributes are not imported. If \fIdeep\fR is TRUE, this function also imports the subtree of \fIimportedNode\fR; otherwise it imports only the element node (and some attributes, see above). TQDomEntity Entity nodes can be imported, but at the moment there is no way to use them since the document type is read-only in DOM level 2. TQDomEntityReference Descendents of entity reference nodes are never imported: \fIdeep\fR has no effect. TQDomNotation Notation nodes can be imported, but at the moment there is no way to use them since the document type is read-only in DOM level 2. TQDomProcessingInstruction The target and value of the processing instruction is copied to the new node. TQDomText The text is copied to the new node. TQDomCDATASection The text is copied to the new node. TQDomComment
See also TQDomElement::setAttribute(), TQDomNode::insertBefore(), TQDomNode::insertAfter(), TQDomNode::replaceChild(), TQDomNode::removeChild(), and TQDomNode::appendChild().
This function parses the XML document from the byte array \fIbuffer\fR and sets it as the content of the document. It tries to detect the encoding of the document as required by the XML specification.
If \fInamespaceProcessing\fR is TRUE, the parser recognizes namespaces in the XML file and sets the prefix name, local name and namespace URI to appropriate values. If \fInamespaceProcessing\fR is FALSE, the parser does no namespace processing when it reads the XML file.
.PP
If a parse error occurs, the function returns FALSE; otherwise it returns TRUE. If a parse error occurs and \fIerrorMsg\fR, \fIerrorLine\fR and \fIerrorColumn\fR are not 0, the error message is placed in \fI*errorMsg\fR, the line number \fI*errorLine\fR and the column number in \fI*errorColumn\fR.
If \fInamespaceProcessing\fR is TRUE, the function TQDomNode::prefix() returns a string for all elements and attributes. It returns an empty string if the element or attribute has no prefix.
This function doesn't change the features of the \fIreader\fR. If you want to use certain features for parsing you can use this function to set up the reader appropriate.