HomeHome

The Qt DOM classes


Introduction to DOM

DOM provides an interface to access and change the content and structure of an XML file. It makes a hierarchical view of the document (tree) available with the root element of the XML file serving as its root. Thus -- in contrast to the SAX2 interface -- an object model of the document is resident in memory after parsing which makes manipulation easy.

In the Qt implementation of the DOM all nodes in the document tree are subclasses of QDomNode. The document itself is represented as a QDomDocument object.

The following table lists the available node classes and their potential children classes.
Node type Possible children
QDomDocument QDomElement (maximum one), QDomProcessingInstruction, QDomComment, QDomDocumentType
QDomDocumentFragment QDomElement, QDomProcessingInstruction, QDomComment, QDomText, QDomCDATASection, QDomEntityReference
QDomDocumentType no children
QDomEntityReference QDomElement, QDomProcessingInstruction, QDomComment, QDomText, QDomCDATASection, QDomEntityReference
QDomElement QDomElement, QDomText, QDomComment, QDomProcessingInstruction, QDomCDATASection, QDomEntityReference
QDomAttr QDomText, QDomEntityReference
QDomProcessingInstruction no children
QDomComment no children
QDomText no children
QDomCDATASection no children
QDomEntity QDomElement, QDomProcessingInstruction, QDomComment, QDomText, QDomCDATASection, QDomEntityReference
QDomNotation no children

With QDomNodeList and QDomNamedNodeMap two collection classes are provided: QDomNodeList is a list of nodes whereas QDomNamedNodeMap is used to handle unordered sets of nodes (often used for attributes).

The QDomImplementation class allows the user to query features of the DOM implementation.

Further reading

To get started please refer to the QDomDocument documentation that describes basic usage.

More information about Qt and XML can be found in the introduction to the Qt XML module.


Copyright © 2000 TrolltechTrademarks
Qt version 2.3.1