You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
505 lines
36 KiB
505 lines
36 KiB
14 years ago
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||
|
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/xml/qdom.cpp:6043 -->
|
||
|
<html>
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||
|
<title>QDomDocument Class</title>
|
||
|
<style type="text/css"><!--
|
||
|
fn { margin-left: 1cm; text-indent: -1cm; }
|
||
|
a:link { color: #004faf; text-decoration: none }
|
||
|
a:visited { color: #672967; text-decoration: none }
|
||
|
body { background: #ffffff; color: black; }
|
||
|
--></style>
|
||
|
</head>
|
||
|
<body>
|
||
|
|
||
|
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
||
|
<tr bgcolor="#E5E5E5">
|
||
|
<td valign=center>
|
||
|
<a href="index.html">
|
||
|
<font color="#004faf">Home</font></a>
|
||
|
| <a href="classes.html">
|
||
|
<font color="#004faf">All Classes</font></a>
|
||
|
| <a href="mainclasses.html">
|
||
|
<font color="#004faf">Main Classes</font></a>
|
||
|
| <a href="annotated.html">
|
||
|
<font color="#004faf">Annotated</font></a>
|
||
|
| <a href="groups.html">
|
||
|
<font color="#004faf">Grouped Classes</font></a>
|
||
|
| <a href="functions.html">
|
||
|
<font color="#004faf">Functions</font></a>
|
||
|
</td>
|
||
|
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QDomDocument Class Reference<br><small>[<a href="xml.html">XML module</a>]</small></h1>
|
||
|
|
||
|
<p>The QDomDocument class represents an XML document.
|
||
|
<a href="#details">More...</a>
|
||
|
<p>All the functions in this class are <a href="threads.html#reentrant">reentrant</a> when Qt is built with thread support.</p>
|
||
|
<p><tt>#include <<a href="qdom-h.html">qdom.h</a>></tt>
|
||
|
<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 class=fn><a href="#QDomDocument"><b>QDomDocument</b></a> ()</li>
|
||
|
<li class=fn>explicit <a href="#QDomDocument-2"><b>QDomDocument</b></a> ( const QString & name )</li>
|
||
|
<li class=fn>explicit <a href="#QDomDocument-3"><b>QDomDocument</b></a> ( const QDomDocumentType & doctype )</li>
|
||
|
<li class=fn><a href="#QDomDocument-4"><b>QDomDocument</b></a> ( const QDomDocument & x )</li>
|
||
|
<li class=fn>QDomDocument & <a href="#operator-eq"><b>operator=</b></a> ( const QDomDocument & x )</li>
|
||
|
<li class=fn><a href="#~QDomDocument"><b>~QDomDocument</b></a> ()</li>
|
||
|
<li class=fn>QDomElement <a href="#createElement"><b>createElement</b></a> ( const QString & tagName )</li>
|
||
|
<li class=fn>QDomDocumentFragment <a href="#createDocumentFragment"><b>createDocumentFragment</b></a> ()</li>
|
||
|
<li class=fn>QDomText <a href="#createTextNode"><b>createTextNode</b></a> ( const QString & value )</li>
|
||
|
<li class=fn>QDomComment <a href="#createComment"><b>createComment</b></a> ( const QString & value )</li>
|
||
|
<li class=fn>QDomCDATASection <a href="#createCDATASection"><b>createCDATASection</b></a> ( const QString & value )</li>
|
||
|
<li class=fn>QDomProcessingInstruction <a href="#createProcessingInstruction"><b>createProcessingInstruction</b></a> ( const QString & target, const QString & data )</li>
|
||
|
<li class=fn>QDomAttr <a href="#createAttribute"><b>createAttribute</b></a> ( const QString & name )</li>
|
||
|
<li class=fn>QDomEntityReference <a href="#createEntityReference"><b>createEntityReference</b></a> ( const QString & name )</li>
|
||
|
<li class=fn>QDomNodeList <a href="#elementsByTagName"><b>elementsByTagName</b></a> ( const QString & tagname ) const</li>
|
||
|
<li class=fn>QDomNode <a href="#importNode"><b>importNode</b></a> ( const QDomNode & importedNode, bool deep )</li>
|
||
|
<li class=fn>QDomElement <a href="#createElementNS"><b>createElementNS</b></a> ( const QString & nsURI, const QString & qName )</li>
|
||
|
<li class=fn>QDomAttr <a href="#createAttributeNS"><b>createAttributeNS</b></a> ( const QString & nsURI, const QString & qName )</li>
|
||
|
<li class=fn>QDomNodeList <a href="#elementsByTagNameNS"><b>elementsByTagNameNS</b></a> ( const QString & nsURI, const QString & localName )</li>
|
||
|
<li class=fn>QDomElement <a href="#elementById"><b>elementById</b></a> ( const QString & elementId )</li>
|
||
|
<li class=fn>QDomDocumentType <a href="#doctype"><b>doctype</b></a> () const</li>
|
||
|
<li class=fn>QDomImplementation <a href="#implementation"><b>implementation</b></a> () const</li>
|
||
|
<li class=fn>QDomElement <a href="#documentElement"><b>documentElement</b></a> () const</li>
|
||
|
<li class=fn>bool <a href="#setContent-2"><b>setContent</b></a> ( const QCString & buffer, bool namespaceProcessing, QString * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )</li>
|
||
|
<li class=fn>bool <a href="#setContent"><b>setContent</b></a> ( const QByteArray & buffer, bool namespaceProcessing, QString * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )</li>
|
||
|
<li class=fn>bool <a href="#setContent-3"><b>setContent</b></a> ( const QString & text, bool namespaceProcessing, QString * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )</li>
|
||
|
<li class=fn>bool <a href="#setContent-4"><b>setContent</b></a> ( QIODevice * dev, bool namespaceProcessing, QString * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )</li>
|
||
|
<li class=fn>bool <a href="#setContent-5"><b>setContent</b></a> ( const QCString & buffer, QString * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )</li>
|
||
|
<li class=fn>bool <a href="#setContent-6"><b>setContent</b></a> ( const QByteArray & buffer, QString * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )</li>
|
||
|
<li class=fn>bool <a href="#setContent-7"><b>setContent</b></a> ( const QString & text, QString * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )</li>
|
||
|
<li class=fn>bool <a href="#setContent-8"><b>setContent</b></a> ( QIODevice * dev, QString * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )</li>
|
||
|
<li class=fn>bool <a href="#setContent-9"><b>setContent</b></a> ( QXmlInputSource * source, QXmlReader * reader, QString * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )</li>
|
||
|
<li class=fn>virtual QDomNode::NodeType <a href="#nodeType"><b>nodeType</b></a> () const</li>
|
||
|
<li class=fn>virtual bool <a href="#isDocument"><b>isDocument</b></a> () const</li>
|
||
|
<li class=fn>QString <a href="#toString"><b>toString</b></a> () const</li>
|
||
|
<li class=fn>QString <a href="#toString-2"><b>toString</b></a> ( int indent ) const</li>
|
||
|
<li class=fn>QCString <a href="#toCString"><b>toCString</b></a> () const</li>
|
||
|
<li class=fn>QCString <a href="#toCString-2"><b>toCString</b></a> ( int indent ) const</li>
|
||
|
</ul>
|
||
|
<hr><a name="details"></a><h2>Detailed Description</h2>
|
||
|
|
||
|
|
||
|
|
||
|
The QDomDocument class represents an XML document.
|
||
|
|
||
|
<p>
|
||
|
|
||
|
<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#ownerDocument">ownerDocument</a>() function
|
||
|
which associates them with the document within whose context they
|
||
|
were created. The DOM classes that will be used most often are
|
||
|
<a href="qdomnode.html">QDomNode</a>, QDomDocument, <a href="qdomelement.html">QDomElement</a> and <a href="qdomtext.html">QDomText</a>.
|
||
|
<p> The parsed XML is represented internally by a tree of objects that
|
||
|
can be accessed using the various QDom classes. All QDom classes
|
||
|
only <em>reference</em> 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 itself are deleted.
|
||
|
<p> Creation of elements, text nodes, etc. is done using the various
|
||
|
factory functions provided in this class. Using the default
|
||
|
constructors of the QDom classes will only result in empty
|
||
|
objects that cannot be manipulated or inserted into the Document.
|
||
|
<p> The QDomDocument class has several functions for creating document
|
||
|
data, for example, <a href="#createElement">createElement</a>(), <a href="#createTextNode">createTextNode</a>(),
|
||
|
<a href="#createComment">createComment</a>(), <a href="#createCDATASection">createCDATASection</a>(),
|
||
|
<a href="#createProcessingInstruction">createProcessingInstruction</a>(), <a href="#createAttribute">createAttribute</a>() and
|
||
|
<a href="#createEntityReference">createEntityReference</a>(). Some of these functions have versions
|
||
|
that support namespaces, i.e. <a href="#createElementNS">createElementNS</a>() and
|
||
|
<a href="#createAttributeNS">createAttributeNS</a>(). The <a href="#createDocumentFragment">createDocumentFragment</a>() function is used
|
||
|
to hold parts of the document; this is useful for manipulating for
|
||
|
complex documents.
|
||
|
<p> The entire content of the document is set with <a href="#setContent">setContent</a>(). 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 <a href="#documentElement">documentElement</a>(). The textual
|
||
|
representation of the document can be obtained using <a href="#toString">toString</a>().
|
||
|
<p> It is possible to insert a node from another document into the
|
||
|
document using <a href="#importNode">importNode</a>().
|
||
|
<p> You can obtain a list of all the elements that have a particular
|
||
|
tag with <a href="#elementsByTagName">elementsByTagName</a>() or with <a href="#elementsByTagNameNS">elementsByTagNameNS</a>().
|
||
|
<p> The QDom classes are typically used as follows:
|
||
|
<pre>
|
||
|
QDomDocument doc( "mydocument" );
|
||
|
<a href="qfile.html">QFile</a> file( "mydocument.xml" );
|
||
|
if ( !file.<a href="qfile.html#open">open</a>( <a href="qfile.html#open">IO_ReadOnly</a> ) )
|
||
|
return;
|
||
|
if ( !doc.<a href="#setContent">setContent</a>( &file ) ) {
|
||
|
file.<a href="qfile.html#close">close</a>();
|
||
|
return;
|
||
|
}
|
||
|
file.<a href="qfile.html#close">close</a>();
|
||
|
|
||
|
// print out the element names of all elements that are direct children
|
||
|
// of the outermost element.
|
||
|
<a href="qdomelement.html">QDomElement</a> docElem = doc.<a href="#documentElement">documentElement</a>();
|
||
|
|
||
|
<a href="qdomnode.html">QDomNode</a> n = docElem.<a href="qdomnode.html#firstChild">firstChild</a>();
|
||
|
while( !n.<a href="qdomnode.html#isNull">isNull</a>() ) {
|
||
|
<a href="qdomelement.html">QDomElement</a> e = n.<a href="qdomnode.html#toElement">toElement</a>(); // try to convert the node to an element.
|
||
|
if( !e.<a href="qdomnode.html#isNull">isNull</a>() ) {
|
||
|
cout << e.<a href="qdomelement.html#tagName">tagName</a>() << endl; // the node really is an element.
|
||
|
}
|
||
|
n = n.<a href="qdomnode.html#nextSibling">nextSibling</a>();
|
||
|
}
|
||
|
|
||
|
// Here we append a new element to the end of the document
|
||
|
<a href="qdomelement.html">QDomElement</a> elem = doc.<a href="#createElement">createElement</a>( "img" );
|
||
|
elem.<a href="qdomelement.html#setAttribute">setAttribute</a>( "src", "myimage.png" );
|
||
|
docElem.<a href="qdomnode.html#appendChild">appendChild</a>( elem );
|
||
|
</pre>
|
||
|
|
||
|
<p> Once <tt>doc</tt> and <tt>elem</tt> go out of scope, the whole internal tree
|
||
|
representing the XML document is deleted.
|
||
|
<p> To create a document using DOM use code like this:
|
||
|
<pre>
|
||
|
QDomDocument doc( "MyML" );
|
||
|
<a href="qdomelement.html">QDomElement</a> root = doc.<a href="#createElement">createElement</a>( "MyML" );
|
||
|
doc.<a href="qdomnode.html#appendChild">appendChild</a>( root );
|
||
|
|
||
|
<a href="qdomelement.html">QDomElement</a> tag = doc.<a href="#createElement">createElement</a>( "Greeting" );
|
||
|
root.<a href="qdomnode.html#appendChild">appendChild</a>( tag );
|
||
|
|
||
|
<a href="qdomtext.html">QDomText</a> t = doc.<a href="#createTextNode">createTextNode</a>( "Hello World" );
|
||
|
tag.<a href="qdomnode.html#appendChild">appendChild</a>( t );
|
||
|
|
||
|
<a href="qstring.html">QString</a> xml = doc.<a href="#toString">toString</a>();
|
||
|
</pre>
|
||
|
|
||
|
<p> For further information about the Document Object Model see
|
||
|
<a href="http://www.w3.org/TR/REC-DOM-Level-1/">http://www.w3.org/TR/REC-DOM-Level-1/</a> and
|
||
|
<a href="http://www.w3.org/TR/DOM-Level-2-Core/">http://www.w3.org/TR/DOM-Level-2-Core/</a>.
|
||
|
For a more general introduction of the DOM implementation see the
|
||
|
QDomDocument documentation.
|
||
|
<p>See also <a href="xml-tools.html">XML</a>.
|
||
|
|
||
|
<hr><h2>Member Function Documentation</h2>
|
||
|
<h3 class=fn><a name="QDomDocument"></a>QDomDocument::QDomDocument ()
|
||
|
</h3>
|
||
|
Constructs an empty document.
|
||
|
|
||
|
<h3 class=fn>explicit <a name="QDomDocument-2"></a>QDomDocument::QDomDocument ( const <a href="qstring.html">QString</a> & name )
|
||
|
</h3>
|
||
|
Creates a document and sets the name of the document type to <em>name</em>.
|
||
|
|
||
|
<h3 class=fn>explicit <a name="QDomDocument-3"></a>QDomDocument::QDomDocument ( const <a href="qdomdocumenttype.html">QDomDocumentType</a> & doctype )
|
||
|
</h3>
|
||
|
Creates a document with the document type <em>doctype</em>.
|
||
|
<p> <p>See also <a href="qdomimplementation.html#createDocumentType">QDomImplementation::createDocumentType</a>().
|
||
|
|
||
|
<h3 class=fn><a name="QDomDocument-4"></a>QDomDocument::QDomDocument ( const <a href="qdomdocument.html">QDomDocument</a> & x )
|
||
|
</h3>
|
||
|
Constructs a copy of <em>x</em>.
|
||
|
<p> The data of the copy is shared (shallow copy): modifying one node
|
||
|
will also change the other. If you want to make a <a href="shclass.html#deep-copy">deep copy</a>, use
|
||
|
<a href="qdomnode.html#cloneNode">cloneNode</a>().
|
||
|
|
||
|
<h3 class=fn><a name="~QDomDocument"></a>QDomDocument::~QDomDocument ()
|
||
|
</h3>
|
||
|
Destroys the object and frees its resources.
|
||
|
|
||
|
<h3 class=fn><a href="qdomattr.html">QDomAttr</a> <a name="createAttribute"></a>QDomDocument::createAttribute ( const <a href="qstring.html">QString</a> & name )
|
||
|
</h3>
|
||
|
Creates a new attribute called <em>name</em> that can be inserted into
|
||
|
an element, e.g. using <a href="qdomelement.html#setAttributeNode">QDomElement::setAttributeNode</a>().
|
||
|
<p> <p>See also <a href="#createAttributeNS">createAttributeNS</a>().
|
||
|
|
||
|
<h3 class=fn><a href="qdomattr.html">QDomAttr</a> <a name="createAttributeNS"></a>QDomDocument::createAttributeNS ( const <a href="qstring.html">QString</a> & nsURI, const <a href="qstring.html">QString</a> & qName )
|
||
|
</h3>
|
||
|
Creates a new attribute with namespace support that can be
|
||
|
inserted into an element. The name of the attribute is <em>qName</em>
|
||
|
and the namespace URI is <em>nsURI</em>. This function also sets
|
||
|
<a href="qdomnode.html#prefix">QDomNode::prefix</a>() and <a href="qdomnode.html#localName">QDomNode::localName</a>() to appropriate values
|
||
|
(depending on <em>qName</em>).
|
||
|
<p> <p>See also <a href="#createAttribute">createAttribute</a>().
|
||
|
|
||
|
<h3 class=fn><a href="qdomcdatasection.html">QDomCDATASection</a> <a name="createCDATASection"></a>QDomDocument::createCDATASection ( const <a href="qstring.html">QString</a> & value )
|
||
|
</h3>
|
||
|
Creates a new CDATA section for the string <em>value</em> that can be
|
||
|
inserted into the document, e.g. using <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>().
|
||
|
<p> <p>See also <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>(), <a href="qdomnode.html#insertBefore">QDomNode::insertBefore</a>(), and <a href="qdomnode.html#insertAfter">QDomNode::insertAfter</a>().
|
||
|
|
||
|
<h3 class=fn><a href="qdomcomment.html">QDomComment</a> <a name="createComment"></a>QDomDocument::createComment ( const <a href="qstring.html">QString</a> & value )
|
||
|
</h3>
|
||
|
Creates a new comment for the string <em>value</em> that can be inserted
|
||
|
into the document, e.g. using <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>().
|
||
|
<p> <p>See also <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>(), <a href="qdomnode.html#insertBefore">QDomNode::insertBefore</a>(), and <a href="qdomnode.html#insertAfter">QDomNode::insertAfter</a>().
|
||
|
|
||
|
<h3 class=fn><a href="qdomdocumentfragment.html">QDomDocumentFragment</a> <a name="createDocumentFragment"></a>QDomDocument::createDocumentFragment ()
|
||
|
</h3>
|
||
|
Creates a new document fragment, that can be used to hold parts of
|
||
|
the document, e.g. when doing complex manipulations of the
|
||
|
document tree.
|
||
|
|
||
|
<h3 class=fn><a href="qdomelement.html">QDomElement</a> <a name="createElement"></a>QDomDocument::createElement ( const <a href="qstring.html">QString</a> & tagName )
|
||
|
</h3>
|
||
|
Creates a new element called <em>tagName</em> that can be inserted into
|
||
|
the DOM tree, e.g. using <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>().
|
||
|
<p> <p>See also <a href="#createElementNS">createElementNS</a>(), <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>(), <a href="qdomnode.html#insertBefore">QDomNode::insertBefore</a>(), and <a href="qdomnode.html#insertAfter">QDomNode::insertAfter</a>().
|
||
|
|
||
|
<h3 class=fn><a href="qdomelement.html">QDomElement</a> <a name="createElementNS"></a>QDomDocument::createElementNS ( const <a href="qstring.html">QString</a> & nsURI, const <a href="qstring.html">QString</a> & qName )
|
||
|
</h3>
|
||
|
Creates a new element with namespace support that can be inserted
|
||
|
into the DOM tree. The name of the element is <em>qName</em> and the
|
||
|
namespace URI is <em>nsURI</em>. This function also sets
|
||
|
<a href="qdomnode.html#prefix">QDomNode::prefix</a>() and <a href="qdomnode.html#localName">QDomNode::localName</a>() to appropriate values
|
||
|
(depending on <em>qName</em>).
|
||
|
<p> <p>See also <a href="#createElement">createElement</a>().
|
||
|
|
||
|
<h3 class=fn><a href="qdomentityreference.html">QDomEntityReference</a> <a name="createEntityReference"></a>QDomDocument::createEntityReference ( const <a href="qstring.html">QString</a> & name )
|
||
|
</h3>
|
||
|
Creates a new entity reference called <em>name</em> that can be inserted
|
||
|
into the document, e.g. using <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>().
|
||
|
<p> <p>See also <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>(), <a href="qdomnode.html#insertBefore">QDomNode::insertBefore</a>(), and <a href="qdomnode.html#insertAfter">QDomNode::insertAfter</a>().
|
||
|
|
||
|
<h3 class=fn><a href="qdomprocessinginstruction.html">QDomProcessingInstruction</a> <a name="createProcessingInstruction"></a>QDomDocument::createProcessingInstruction ( const <a href="qstring.html">QString</a> & target, const <a href="qstring.html">QString</a> & data )
|
||
|
</h3>
|
||
|
Creates a new processing instruction that can be inserted into the
|
||
|
document, e.g. using <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>(). This function sets
|
||
|
the target for the processing instruction to <em>target</em> and the
|
||
|
data to <em>data</em>.
|
||
|
<p> <p>See also <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>(), <a href="qdomnode.html#insertBefore">QDomNode::insertBefore</a>(), and <a href="qdomnode.html#insertAfter">QDomNode::insertAfter</a>().
|
||
|
|
||
|
<h3 class=fn><a href="qdomtext.html">QDomText</a> <a name="createTextNode"></a>QDomDocument::createTextNode ( const <a href="qstring.html">QString</a> & value )
|
||
|
</h3>
|
||
|
Creates a text node for the string <em>value</em> that can be inserted
|
||
|
into the document tree, e.g. using <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>().
|
||
|
<p> <b>Warning:</b> All characters within an XML document must be in the range:
|
||
|
<p> #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
|
||
|
<p> 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.
|
||
|
<p> 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.
|
||
|
<p> <p>See also <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>(), <a href="qdomnode.html#insertBefore">QDomNode::insertBefore</a>(), and <a href="qdomnode.html#insertAfter">QDomNode::insertAfter</a>().
|
||
|
|
||
|
<h3 class=fn><a href="qdomdocumenttype.html">QDomDocumentType</a> <a name="doctype"></a>QDomDocument::doctype () const
|
||
|
</h3>
|
||
|
Returns the document type of this document.
|
||
|
|
||
|
<h3 class=fn><a href="qdomelement.html">QDomElement</a> <a name="documentElement"></a>QDomDocument::documentElement () const
|
||
|
</h3>
|
||
|
Returns the root element of the document.
|
||
|
|
||
|
<h3 class=fn><a href="qdomelement.html">QDomElement</a> <a name="elementById"></a>QDomDocument::elementById ( const <a href="qstring.html">QString</a> & elementId )
|
||
|
</h3>
|
||
|
Returns the element whose ID is equal to <em>elementId</em>. If no
|
||
|
element with the ID was found, this function returns a <a href="qdomnode.html#isNull">null element</a>.
|
||
|
<p> Since the QDomClasses do not know which attributes are element
|
||
|
IDs, this function returns always a <a href="qdomnode.html#isNull">null
|
||
|
element</a>. This may change in a future version.
|
||
|
|
||
|
<h3 class=fn><a href="qdomnodelist.html">QDomNodeList</a> <a name="elementsByTagName"></a>QDomDocument::elementsByTagName ( const <a href="qstring.html">QString</a> & tagname ) const
|
||
|
</h3>
|
||
|
Returns a <a href="qdomnodelist.html">QDomNodeList</a>, that contains all the elements in the
|
||
|
document with the name <em>tagname</em>. The order of the node list is
|
||
|
the order they are encountered in a preorder traversal of the
|
||
|
element tree.
|
||
|
<p> <p>See also <a href="#elementsByTagNameNS">elementsByTagNameNS</a>() and <a href="qdomelement.html#elementsByTagName">QDomElement::elementsByTagName</a>().
|
||
|
|
||
|
<h3 class=fn><a href="qdomnodelist.html">QDomNodeList</a> <a name="elementsByTagNameNS"></a>QDomDocument::elementsByTagNameNS ( const <a href="qstring.html">QString</a> & nsURI, const <a href="qstring.html">QString</a> & localName )
|
||
|
</h3>
|
||
|
Returns a <a href="qdomnodelist.html">QDomNodeList</a> that contains all the elements in the
|
||
|
document with the local name <em>localName</em> and a namespace URI of
|
||
|
<em>nsURI</em>. The order of the node list is the order they are
|
||
|
encountered in a preorder traversal of the element tree.
|
||
|
<p> <p>See also <a href="#elementsByTagName">elementsByTagName</a>() and <a href="qdomelement.html#elementsByTagNameNS">QDomElement::elementsByTagNameNS</a>().
|
||
|
|
||
|
<h3 class=fn><a href="qdomimplementation.html">QDomImplementation</a> <a name="implementation"></a>QDomDocument::implementation () const
|
||
|
</h3>
|
||
|
Returns a <a href="qdomimplementation.html">QDomImplementation</a> object.
|
||
|
|
||
|
<h3 class=fn><a href="qdomnode.html">QDomNode</a> <a name="importNode"></a>QDomDocument::importNode ( const <a href="qdomnode.html">QDomNode</a> & importedNode, bool deep )
|
||
|
</h3>
|
||
|
Imports the node <em>importedNode</em> from another document to this
|
||
|
document. <em>importedNode</em> remains in the original document; this
|
||
|
function creates a copy that can be used within this document.
|
||
|
<p> This function returns the imported node that belongs to this
|
||
|
document. The returned node has no parent. It is not possible to
|
||
|
import QDomDocument and <a href="qdomdocumenttype.html">QDomDocumentType</a> nodes. In those cases
|
||
|
this function returns a <a href="qdomnode.html#isNull">null node</a>.
|
||
|
<p> If <em>deep</em> is TRUE, this function imports not only the node <em>importedNode</em> but its whole subtree; if it is FALSE, only the <em>importedNode</em> is imported. The argument <em>deep</em> has no effect on
|
||
|
<a href="qdomattr.html">QDomAttr</a> and <a href="qdomentityreference.html">QDomEntityReference</a> nodes, since the descendents of
|
||
|
QDomAttr nodes are always imported and those of
|
||
|
QDomEntityReference nodes are never imported.
|
||
|
<p> The behavior of this function is slightly different depending on
|
||
|
the node types:
|
||
|
<center><table cellpadding="4" cellspacing="2" border="0">
|
||
|
<tr bgcolor="#a2c511"> <th valign="top">Node Type <th valign="top">Behaviour
|
||
|
<tr bgcolor="#f0f0f0"> <td valign="top">QDomAttr
|
||
|
<td valign="top">The owner element is set to 0 and the specified flag is
|
||
|
set to TRUE in the generated attribute. The whole subtree
|
||
|
of <em>importedNode</em> is always imported for attribute nodes:
|
||
|
<em>deep</em> has no effect.
|
||
|
<tr bgcolor="#d0d0d0"> <td valign="top">QDomDocument
|
||
|
<td valign="top">Document nodes cannot be imported.
|
||
|
<tr bgcolor="#f0f0f0"> <td valign="top">QDomDocumentFragment
|
||
|
<td valign="top">If <em>deep</em> is TRUE, this function imports the whole
|
||
|
document fragment; otherwise it only generates an empty
|
||
|
document fragment.
|
||
|
<tr bgcolor="#d0d0d0"> <td valign="top">QDomDocumentType
|
||
|
<td valign="top">Document type nodes cannot be imported.
|
||
|
<tr bgcolor="#f0f0f0"> <td valign="top">QDomElement
|
||
|
<td valign="top">Attributes for which <a href="qdomattr.html#specified">QDomAttr::specified</a>() is TRUE are
|
||
|
also imported, other attributes are not imported. If <em>deep</em> is TRUE, this function also imports the subtree of <em>importedNode</em>; otherwise it imports only the element node
|
||
|
(and some attributes, see above).
|
||
|
<tr bgcolor="#d0d0d0"> <td valign="top">QDomEntity
|
||
|
<td valign="top">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.
|
||
|
<tr bgcolor="#f0f0f0"> <td valign="top">QDomEntityReference
|
||
|
<td valign="top">Descendents of entity reference nodes are never imported:
|
||
|
<em>deep</em> has no effect.
|
||
|
<tr bgcolor="#d0d0d0"> <td valign="top">QDomNotation
|
||
|
<td valign="top">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.
|
||
|
<tr bgcolor="#f0f0f0"> <td valign="top">QDomProcessingInstruction
|
||
|
<td valign="top">The target and value of the processing instruction is
|
||
|
copied to the new node.
|
||
|
<tr bgcolor="#d0d0d0"> <td valign="top">QDomText
|
||
|
<td valign="top">The text is copied to the new node.
|
||
|
<tr bgcolor="#f0f0f0"> <td valign="top">QDomCDATASection
|
||
|
<td valign="top">The text is copied to the new node.
|
||
|
<tr bgcolor="#d0d0d0"> <td valign="top">QDomComment
|
||
|
<td valign="top">The text is copied to the new node.
|
||
|
</table></center>
|
||
|
<p> <p>See also <a href="qdomelement.html#setAttribute">QDomElement::setAttribute</a>(), <a href="qdomnode.html#insertBefore">QDomNode::insertBefore</a>(), <a href="qdomnode.html#insertAfter">QDomNode::insertAfter</a>(), <a href="qdomnode.html#replaceChild">QDomNode::replaceChild</a>(), <a href="qdomnode.html#removeChild">QDomNode::removeChild</a>(), and <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>().
|
||
|
|
||
|
<h3 class=fn>bool <a name="isDocument"></a>QDomDocument::isDocument () const<tt> [virtual]</tt>
|
||
|
</h3>
|
||
|
Returns TRUE.
|
||
|
|
||
|
<p>Reimplemented from <a href="qdomnode.html#isDocument">QDomNode</a>.
|
||
|
<h3 class=fn><a href="qdomnode.html#NodeType-enum">QDomNode::NodeType</a> <a name="nodeType"></a>QDomDocument::nodeType () const<tt> [virtual]</tt>
|
||
|
</h3>
|
||
|
Returns <a href="qdomnode.html#NodeType-enum">DocumentNode</a>.
|
||
|
|
||
|
<p>Reimplemented from <a href="qdomnode.html#nodeType">QDomNode</a>.
|
||
|
<h3 class=fn><a href="qdomdocument.html">QDomDocument</a> & <a name="operator-eq"></a>QDomDocument::operator= ( const <a href="qdomdocument.html">QDomDocument</a> & x )
|
||
|
</h3>
|
||
|
Assigns <em>x</em> to this DOM document.
|
||
|
<p> The data of the copy is shared (shallow copy): modifying one node
|
||
|
will also change the other. If you want to make a <a href="shclass.html#deep-copy">deep copy</a>, use
|
||
|
<a href="qdomnode.html#cloneNode">cloneNode</a>().
|
||
|
|
||
|
<h3 class=fn>bool <a name="setContent"></a>QDomDocument::setContent ( const <a href="qbytearray.html">QByteArray</a> & buffer, bool namespaceProcessing, <a href="qstring.html">QString</a> * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )
|
||
|
</h3>
|
||
|
This function parses the XML document from the byte array <em>buffer</em> and sets it as the content of the document. It tries to
|
||
|
detect the encoding of the document as required by the XML
|
||
|
specification.
|
||
|
<p> If <em>namespaceProcessing</em> is TRUE, the parser recognizes
|
||
|
namespaces in the XML file and sets the prefix name, local name
|
||
|
and namespace URI to appropriate values. If <em>namespaceProcessing</em>
|
||
|
is FALSE, the parser does no namespace processing when it reads
|
||
|
the XML file.
|
||
|
<p> If a parse error occurs, the function returns FALSE; otherwise it
|
||
|
returns TRUE. If a parse error occurs and <em>errorMsg</em>, <em>errorLine</em> and <em>errorColumn</em> are not 0, the error message is
|
||
|
placed in <em>*errorMsg</em>, the line number <em>*errorLine</em> and the
|
||
|
column number in <em>*errorColumn</em>.
|
||
|
<p> If <em>namespaceProcessing</em> is TRUE, the function <a href="qdomnode.html#prefix">QDomNode::prefix</a>()
|
||
|
returns a string for all elements and attributes. It returns an
|
||
|
empty string if the element or attribute has no prefix.
|
||
|
<p> If <em>namespaceProcessing</em> is FALSE, the functions
|
||
|
QDomNode::prefix(), <a href="qdomnode.html#localName">QDomNode::localName</a>() and
|
||
|
<a href="qdomnode.html#namespaceURI">QDomNode::namespaceURI</a>() return <a href="qstring.html#QString-null">QString::null</a>.
|
||
|
<p> <p>See also <a href="qdomnode.html#namespaceURI">QDomNode::namespaceURI</a>(), <a href="qdomnode.html#localName">QDomNode::localName</a>(), <a href="qdomnode.html#prefix">QDomNode::prefix</a>(), <a href="qstring.html#isNull">QString::isNull</a>(), and <a href="qstring.html#isEmpty">QString::isEmpty</a>().
|
||
|
|
||
|
<h3 class=fn>bool <a name="setContent-2"></a>QDomDocument::setContent ( const <a href="qcstring.html">QCString</a> & buffer, bool namespaceProcessing, <a href="qstring.html">QString</a> * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )
|
||
|
</h3>
|
||
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
||
|
<p> This function reads the XML document from the C string <em>buffer</em>.
|
||
|
<p> <b>Warning:</b> This function does not try to detect the encoding:
|
||
|
instead it assumes that the C string is UTF-8 encoded.
|
||
|
|
||
|
<h3 class=fn>bool <a name="setContent-3"></a>QDomDocument::setContent ( const <a href="qstring.html">QString</a> & text, bool namespaceProcessing, <a href="qstring.html">QString</a> * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )
|
||
|
</h3>
|
||
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
||
|
<p> This function reads the XML document from the string <em>text</em>.
|
||
|
Since <em>text</em> is already a Unicode string, no encoding detection
|
||
|
is done.
|
||
|
|
||
|
<h3 class=fn>bool <a name="setContent-4"></a>QDomDocument::setContent ( <a href="qiodevice.html">QIODevice</a> * dev, bool namespaceProcessing, <a href="qstring.html">QString</a> * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )
|
||
|
</h3>
|
||
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
||
|
<p> This function reads the XML document from the IO device <em>dev</em>.
|
||
|
|
||
|
<h3 class=fn>bool <a name="setContent-5"></a>QDomDocument::setContent ( const <a href="qcstring.html">QCString</a> & buffer, <a href="qstring.html">QString</a> * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )
|
||
|
</h3>
|
||
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
||
|
<p> This function reads the XML document from the C string <em>buffer</em>.
|
||
|
<p> No namespace processing is performed.
|
||
|
<p> <b>Warning:</b> This function does not try to detect the encoding:
|
||
|
instead it assumes that the C string is UTF-8 encoded.
|
||
|
|
||
|
<h3 class=fn>bool <a name="setContent-6"></a>QDomDocument::setContent ( const <a href="qbytearray.html">QByteArray</a> & buffer, <a href="qstring.html">QString</a> * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )
|
||
|
</h3>
|
||
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
||
|
<p> This function reads the XML document from the byte array <em>buffer</em>.
|
||
|
<p> No namespace processing is performed.
|
||
|
|
||
|
<h3 class=fn>bool <a name="setContent-7"></a>QDomDocument::setContent ( const <a href="qstring.html">QString</a> & text, <a href="qstring.html">QString</a> * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )
|
||
|
</h3>
|
||
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
||
|
<p> This function reads the XML document from the string <em>text</em>.
|
||
|
Since <em>text</em> is already a Unicode string, no encoding detection
|
||
|
is performed.
|
||
|
<p> No namespace processing is performed either.
|
||
|
|
||
|
<h3 class=fn>bool <a name="setContent-8"></a>QDomDocument::setContent ( <a href="qiodevice.html">QIODevice</a> * dev, <a href="qstring.html">QString</a> * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )
|
||
|
</h3>
|
||
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
||
|
<p> This function reads the XML document from the IO device <em>dev</em>.
|
||
|
<p> No namespace processing is performed.
|
||
|
|
||
|
<h3 class=fn>bool <a name="setContent-9"></a>QDomDocument::setContent ( <a href="qxmlinputsource.html">QXmlInputSource</a> * source, <a href="qxmlreader.html">QXmlReader</a> * reader, <a href="qstring.html">QString</a> * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )
|
||
|
</h3>
|
||
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
||
|
<p> This function reads the XML document from the <a href="qxmlinputsource.html">QXmlInputSource</a> <em>source</em> and
|
||
|
parses it with the <a href="qxmlreader.html">QXmlReader</a> <em>reader</em>.
|
||
|
<p> This function doesn't change the features of the <em>reader</em>. If you want to
|
||
|
use certain features for parsing you can use this function to set up the
|
||
|
reader appropriate.
|
||
|
<p> <p>See also <a href="qxmlsimplereader.html">QXmlSimpleReader</a>.
|
||
|
|
||
|
<h3 class=fn><a href="qcstring.html">QCString</a> <a name="toCString"></a>QDomDocument::toCString () const
|
||
|
</h3>
|
||
|
Converts the parsed document back to its textual representation
|
||
|
and returns a <a href="qcstring.html">QCString</a> for that is encoded in UTF-8.
|
||
|
<p> <p>See also <a href="#toString">toString</a>().
|
||
|
|
||
|
<h3 class=fn><a href="qcstring.html">QCString</a> <a name="toCString-2"></a>QDomDocument::toCString ( int indent ) const
|
||
|
</h3>
|
||
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
||
|
<p> This function uses <em>indent</em> as the amount of space to indent
|
||
|
subelements.
|
||
|
|
||
|
<h3 class=fn><a href="qstring.html">QString</a> <a name="toString"></a>QDomDocument::toString () const
|
||
|
</h3>
|
||
|
Converts the parsed document back to its textual representation.
|
||
|
<p> <p>See also <a href="#toCString">toCString</a>().
|
||
|
|
||
|
<h3 class=fn><a href="qstring.html">QString</a> <a name="toString-2"></a>QDomDocument::toString ( int indent ) const
|
||
|
</h3>
|
||
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
||
|
<p> This function uses <em>indent</em> as the amount of space to indent
|
||
|
subelements.
|
||
|
|
||
|
<!-- eof -->
|
||
|
<hr><p>
|
||
|
This file is part of the <a href="index.html">Qt toolkit</a>.
|
||
|
Copyright © 1995-2007
|
||
|
<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 © 2007
|
||
|
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
||
|
<td align=right><div align=right>Qt 3.3.8</div>
|
||
|
</table></div></address></body>
|
||
|
</html>
|