1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Qt Toolkit - QDomDocument Class</title><style type="text/css"><!--
h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }body { background: white; color: black; }
--></style>
</head><body bgcolor="#ffffff">
<table width="100%">
<tr><td><a href="index.html">
<img width="100" height="100" src="qtlogo.png"
alt="Home" border="0"><img width="100"
height="100" src="face.png" alt="Home" border="0">
</a><td valign=top><div align=right><img src="dochead.png" width="472" height="27"><br>
<a href="classes.html"><b>Classes</b></a>
-<a href="annotated.html">Annotated</a>
- <a href="hierarchy.html">Tree</a>
-<a href="functions.html">Functions</a>
-<a href="index.html">Home</a>
-<a href="topicals.html"><b>Structure</b></a>
</div>
</table>
<h1 align=center>QDomDocument Class Reference<br><small>[ <a href="xml.html">XML module</a> ]</small></h1><br clear="all">
<p>
The QDomDocument class is the representation of an XML document.
<a href="#details">More...</a>
<p>
<code>#include <<a href="qdom-h.html">qdom.h</a>></code>
<p>
Inherits <a href="qdomnode.html">QDomNode</a>.
<p><a href="qdomdocument-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><div class="fn"><a href="#7c715c"><b>QDomDocument</b></a>()</div>
<li><div class="fn"><a href="#cf93cf"><b>QDomDocument</b></a>(constQString&name)</div>
<li><div class="fn"><a href="#28212b"><b>QDomDocument</b></a>(constQDomDocument&x)</div>
<li><div class="fn">QDomDocument&<a href="#20a0e1"><b>operator=</b></a>(constQDomDocument&)</div>
<li><div class="fn"><a href="#799cd6"><b>~QDomDocument</b></a>()</div>
<li><div class="fn">bool<a href="#ed2360"><b>setContent</b></a>(constQCString&text)</div>
<li><div class="fn">bool<a href="#b62f14"><b>setContent</b></a>(constQByteArray&text)</div>
<li><div class="fn">bool<a href="#6d6711"><b>setContent</b></a>(constQString&text)</div>
<li><div class="fn">bool<a href="#6512b3"><b>setContent</b></a>(QIODevice*dev)</div>
<li><div class="fn">QDomDocumentType<a href="#eb0d40"><b>doctype</b></a>()const</div>
<li><div class="fn">QDomImplementation<a href="#3a9eb3"><b>implementation</b></a>()const</div>
<li><div class="fn">QDomElement<a href="#bb6e6a"><b>documentElement</b></a>()const</div>
<li><div class="fn">QDomElement<a href="#33fa01"><b>createElement</b></a>(constQString&tagName)</div>
<li><div class="fn">QDomDocumentFragment<a href="#d22cc2"><b>createDocumentFragment</b></a>()</div>
<li><div class="fn">QDomText<a href="#95c9fe"><b>createTextNode</b></a>(constQString&data)</div>
<li><div class="fn">QDomComment<a href="#91fc76"><b>createComment</b></a>(constQString&data)</div>
<li><div class="fn">QDomCDATASection<a href="#735338"><b>createCDATASection</b></a>(constQString&data)</div>
<li><div class="fn">QDomProcessingInstruction<a href="#d4a4b6"><b>createProcessingInstruction</b></a>(constQString&target, constQString&data)</div>
<li><div class="fn">QDomAttr<a href="#d33c6d"><b>createAttribute</b></a>(constQString&name)</div>
<li><div class="fn">QDomEntityReference<a href="#136958"><b>createEntityReference</b></a>(constQString&name)</div>
<li><div class="fn">QDomNodeList<a href="#c2d794"><b>elementsByTagName</b></a>(constQString&tagname)const</div>
<li><div class="fn">virtualQDomNode::NodeType<a href="#d63184"><b>nodeType</b></a>()const</div>
<li><div class="fn">virtualbool<a href="#d2d187"><b>isDocument</b></a>()const</div>
<li><div class="fn">QString<a href="#a1e345"><b>toString</b></a>()const</div>
<li><div class="fn">QCString<a href="#91051b"><b>toCString</b></a>()const</div>
</ul>
<hr><h2><a name="details"></a>Detailed Description</h2>
The QDomDocument class is the representation of an XML document.
<p>
The QDomDocument 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.
<p>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 <a href="qdomnode.html#3a3219">ownerDocument</a>() function which associates them with the document
within whose context they were created.
<p>The parsed XML is represented internally by a tree of objects that can be
accessed using the various QDom classes. All QDom classes do only reference
objects in the internal tree. The internal objects in the DOM tree will get
deleted, once the last QDom object referencing them and the QDomDocument are
deleted.
<p>Creation of elements, text nodes, etc. is done via the various factory
functions provided in this class. Using the default constructors of the QDom
classes will only result in empty objects, that can not be manipulated or
inserted into the Document.
<p>The QDom classes are typically used as follows:
<pre> <a href="qdomdocument.html">QDomDocument</a> doc( "mydocument" );
<a href="qfile.html">QFile</a> f( "mydocument.xml" );
if ( !f.<a href="qfile.html#255995">open</a>( IO_ReadOnly ) )
return;
if ( !doc.<a href="#6d6711">setContent</a>( &f ) ) {
f.<a href="qfile.html#64e640">close</a>();
return;
}
f.<a href="qfile.html#64e640">close</a>();
// print out the element names of all elements that are a direct child
// of the outermost element.
<a href="qdomelement.html">QDomElement</a> docElem = doc.<a href="#bb6e6a">documentElement</a>();
<a href="qdomnode.html">QDomNode</a> n = docElem.<a href="qdomnode.html#b061e7">firstChild</a>();
while( !n.<a href="qdomnode.html#cb0c9f">isNull</a>() ) {
<a href="qdomelement.html">QDomElement</a> e = n.<a href="qdomnode.html#fb4b8a">toElement</a>(); // try to convert the node to an element.
if( !e.<a href="qdomnode.html#cb0c9f">isNull</a>() ) { // the node was really an element.
cout << e.<a href="qdomelement.html#028cbe">tagName</a>() << endl;
}
n = n.<a href="qdomnode.html#491892">nextSibling</a>();
}
// lets append a new element to the end of the document
<a href="qdomelement.html">QDomElement</a> elem = doc.<a href="#33fa01">createElement</a>( "img" );
elem.<a href="qdomelement.html#9d5719">setAttribute</a>( "src", "myimage.png" );
docElem.<a href="qdomnode.html#b74d0e">appendChild</a>( elem );
</pre>
<p>Once <code>doc</code> and <code>elem</code> go out of scode, the whole internal tree representing
the XML document will get deleted.
<p>For further information about the Document Objct Model see
<a href="http://www.w3.org/TR/REC-DOM-Level-1/">http://www.w3.org/TR/REC-DOM-Level-1/</a>
<hr><h2>Member Function Documentation</h2>
<h3 class="fn"><a name="7c715c"></a>QDomDocument::QDomDocument()</h3>
<p>Constructs an empty document.
<h3 class="fn"><a name="cf93cf"></a>QDomDocument::QDomDocument(const<a href="qstring.html">QString</a>&name)</h3>
<p>Creates a document with the name <em>name.</em>
<h3 class="fn"><a name="28212b"></a>QDomDocument::QDomDocument(constQDomDocument&x)</h3>
<p>Copy constructor.
<p>The data of the copy is shared: modifying one will also change the other. If
you want to make a real copy, use <a href="qdomnode.html#8f17f1">cloneNode</a>() instead.
<h3 class="fn"><a name="799cd6"></a>QDomDocument::~QDomDocument()</h3>
<p>Destructor.
<h3 class="fn"><a href="qdomattr.html">QDomAttr</a><a name="d33c6d"></a>QDomDocument::createAttribute(const<a href="qstring.html">QString</a>&name)</h3>
<p>Creates a new attribute that can be inserted into an element.
<h3 class="fn"><a href="qdomcdatasection.html">QDomCDATASection</a><a name="735338"></a>QDomDocument::createCDATASection(const<a href="qstring.html">QString</a>&value)</h3>
<p>Creates a new CDATA section that can be inserted into the document.
<h3 class="fn"><a href="qdomcomment.html">QDomComment</a><a name="91fc76"></a>QDomDocument::createComment(const<a href="qstring.html">QString</a>&value)</h3>
<p>Creates a new comment that can be inserted into the Document.
<h3 class="fn"><a href="qdomdocumentfragment.html">QDomDocumentFragment</a><a name="d22cc2"></a>QDomDocument::createDocumentFragment()</h3>
<p>Creates a new document fragment, that can be used to hold parts
of the document, when doing complex manipulations of the document tree.
<h3 class="fn"><a href="qdomelement.html">QDomElement</a><a name="33fa01"></a>QDomDocument::createElement(const<a href="qstring.html">QString</a>&tagName)</h3>
<p>Creates a new element with the name <em>tagName</em> that can be inserted into the
DOM tree.
<h3 class="fn"><a href="qdomentityreference.html">QDomEntityReference</a><a name="136958"></a>QDomDocument::createEntityReference(const<a href="qstring.html">QString</a>&name)</h3>
<p>Creates a new entity reference.
<h3 class="fn"><a href="qdomprocessinginstruction.html">QDomProcessingInstruction</a><a name="d4a4b6"></a>QDomDocument::createProcessingInstruction(const<a href="qstring.html">QString</a>&target, const<a href="qstring.html">QString</a>&data)</h3>
<p>Creates a new processing instruction that can be inserted into the document.
<h3 class="fn"><a href="qdomtext.html">QDomText</a><a name="95c9fe"></a>QDomDocument::createTextNode(const<a href="qstring.html">QString</a>&value)</h3>
<p>Creates a text node that can be inserted into the document tree.
<h3 class="fn"><a href="qdomdocumenttype.html">QDomDocumentType</a><a name="eb0d40"></a>QDomDocument::doctype()const</h3>
<p>Returns the document type of this document.
<h3 class="fn"><a href="qdomelement.html">QDomElement</a><a name="bb6e6a"></a>QDomDocument::documentElement()const</h3>
<p>Returns the root element of the document.
<h3 class="fn"><a href="qdomnodelist.html">QDomNodeList</a><a name="c2d794"></a>QDomDocument::elementsByTagName(const<a href="qstring.html">QString</a>&tagname)const</h3>
<p>Returns a <a href="qdomnodelist.html">QDomNodeList</a>, that contains all elements in the document
with the tag name <em>tagname.</em> The order of the node list, is the
order they are encountered in a preorder traversal of the element tree.
<h3 class="fn"><a href="qdomimplementation.html">QDomImplementation</a><a name="3a9eb3"></a>QDomDocument::implementation()const</h3>
<p>Returns a <a href="qdomimplementation.html">QDomImplementation</a> object.
<h3 class="fn">bool<a name="d2d187"></a>QDomDocument::isDocument()const <code>[virtual]</code></h3>
<p>Returns TRUE.
<p>Reimplemented from <a href="qdomnode.html#fb265b">QDomNode.</a>
<h3 class="fn">QDomNode::NodeType<a name="d63184"></a>QDomDocument::nodeType()const <code>[virtual]</code></h3>
<p>Returns <code>DocumentNode.</code>
<p>Reimplemented from <a href="qdomnode.html#46495e">QDomNode.</a>
<h3 class="fn">QDomDocument&<a name="20a0e1"></a>QDomDocument::operator=(constQDomDocument&x)</h3>
<p>Assignment operator.
<p>The data of the copy is shared: modifying one will also change the other. If
you want to make a real copy, use <a href="qdomnode.html#8f17f1">cloneNode</a>() instead.
<h3 class="fn">bool<a name="6d6711"></a>QDomDocument::setContent(const<a href="qstring.html">QString</a>&text)</h3>
<p>This function parses the string <em>text</em> and sets it as the content of the
document.
<h3 class="fn">bool<a name="6512b3"></a>QDomDocument::setContent(<a href="qiodevice.html">QIODevice</a>*dev)</h3>
<p>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
<h3 class="fn">bool<a name="b62f14"></a>QDomDocument::setContent(const<a href="qbytearray.html">QByteArray</a>&buffer)</h3>
<p>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
<h3 class="fn">bool<a name="ed2360"></a>QDomDocument::setContent(const<a href="qcstring.html">QCString</a>&buffer)</h3>
<p>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
<h3 class="fn"><a href="qcstring.html">QCString</a><a name="91051b"></a>QDomDocument::toCString()const</h3>
<p>Converts the parsed document back to its textual representation.
<h3 class="fn"><a href="qstring.html">QString</a><a name="a1e345"></a>QDomDocument::toString()const</h3>
<p>Converts the parsed document back to its textual representation.
<hr><p>
Search the documentation, FAQ, qt-interest archive and more (uses
<a href="http://www.trolltech.com">www.trolltech.com</a>):<br>
<form method=post action="http://www.trolltech.com/search.cgi">
<input type=hidden name="version" value="2.3.2"><nobr>
<input size="50" name="search"><input type=submit value="Search">
</nobr></form><hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>,
copyright © 1995-2001
<a href="http://www.trolltech.com">Trolltech</a>, all rights reserved.<p><address><hr><div align="center">
<table width="100%" cellspacing="0" border="0"><tr>
<td>Copyright 2001 Trolltech<td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align="right"><div align="right">Qt version 2.3.2</div>
</table></div></address></body></html>
|