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.
tqt3/doc/html/tqdomdocument.html

504 lines
36 KiB

<!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>TQDomDocument 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&nbsp;Classes</font></a>
| <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
| <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
| <a href="groups.html">
<font color="#004faf">Grouped&nbsp;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>TQDomDocument Class Reference<br><small>[<a href="xml.html">XML module</a>]</small></h1>
<p>The TQDomDocument 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 TQt is built with thread support.</p>
<p><tt>#include &lt;<a href="tqdom-h.html">tqdom.h</a>&gt;</tt>
<p>Inherits <a href="tqdomnode.html">TQDomNode</a>.
<p><a href="tqdomdocument-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn><a href="#TQDomDocument"><b>TQDomDocument</b></a> ()</li>
<li class=fn>explicit <a href="#TQDomDocument-2"><b>TQDomDocument</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;name )</li>
<li class=fn>explicit <a href="#TQDomDocument-3"><b>TQDomDocument</b></a> ( const&nbsp;TQDomDocumentType&nbsp;&amp;&nbsp;doctype )</li>
<li class=fn><a href="#TQDomDocument-4"><b>TQDomDocument</b></a> ( const&nbsp;TQDomDocument&nbsp;&amp;&nbsp;x )</li>
<li class=fn>TQDomDocument &amp; <a href="#operator-eq"><b>operator=</b></a> ( const&nbsp;TQDomDocument&nbsp;&amp;&nbsp;x )</li>
<li class=fn><a href="#~TQDomDocument"><b>~TQDomDocument</b></a> ()</li>
<li class=fn>TQDomElement <a href="#createElement"><b>createElement</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;tagName )</li>
<li class=fn>TQDomDocumentFragment <a href="#createDocumentFragment"><b>createDocumentFragment</b></a> ()</li>
<li class=fn>TQDomText <a href="#createTextNode"><b>createTextNode</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;value )</li>
<li class=fn>TQDomComment <a href="#createComment"><b>createComment</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;value )</li>
<li class=fn>TQDomCDATASection <a href="#createCDATASection"><b>createCDATASection</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;value )</li>
<li class=fn>TQDomProcessingInstruction <a href="#createProcessingInstruction"><b>createProcessingInstruction</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;target, const&nbsp;TQString&nbsp;&amp;&nbsp;data )</li>
<li class=fn>TQDomAttr <a href="#createAttribute"><b>createAttribute</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;name )</li>
<li class=fn>TQDomEntityReference <a href="#createEntityReference"><b>createEntityReference</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;name )</li>
<li class=fn>TQDomNodeList <a href="#elementsByTagName"><b>elementsByTagName</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;tagname ) const</li>
<li class=fn>TQDomNode <a href="#importNode"><b>importNode</b></a> ( const&nbsp;TQDomNode&nbsp;&amp;&nbsp;importedNode, bool&nbsp;deep )</li>
<li class=fn>TQDomElement <a href="#createElementNS"><b>createElementNS</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;nsURI, const&nbsp;TQString&nbsp;&amp;&nbsp;qName )</li>
<li class=fn>TQDomAttr <a href="#createAttributeNS"><b>createAttributeNS</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;nsURI, const&nbsp;TQString&nbsp;&amp;&nbsp;qName )</li>
<li class=fn>TQDomNodeList <a href="#elementsByTagNameNS"><b>elementsByTagNameNS</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;nsURI, const&nbsp;TQString&nbsp;&amp;&nbsp;localName )</li>
<li class=fn>TQDomElement <a href="#elementById"><b>elementById</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;elementId )</li>
<li class=fn>TQDomDocumentType <a href="#doctype"><b>doctype</b></a> () const</li>
<li class=fn>TQDomImplementation <a href="#implementation"><b>implementation</b></a> () const</li>
<li class=fn>TQDomElement <a href="#documentElement"><b>documentElement</b></a> () const</li>
<li class=fn>bool <a href="#setContent-2"><b>setContent</b></a> ( const&nbsp;TQCString&nbsp;&amp;&nbsp;buffer, bool&nbsp;namespaceProcessing, TQString&nbsp;*&nbsp;errorMsg = 0, int&nbsp;*&nbsp;errorLine = 0, int&nbsp;*&nbsp;errorColumn = 0 )</li>
<li class=fn>bool <a href="#setContent"><b>setContent</b></a> ( const&nbsp;TQByteArray&nbsp;&amp;&nbsp;buffer, bool&nbsp;namespaceProcessing, TQString&nbsp;*&nbsp;errorMsg = 0, int&nbsp;*&nbsp;errorLine = 0, int&nbsp;*&nbsp;errorColumn = 0 )</li>
<li class=fn>bool <a href="#setContent-3"><b>setContent</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;text, bool&nbsp;namespaceProcessing, TQString&nbsp;*&nbsp;errorMsg = 0, int&nbsp;*&nbsp;errorLine = 0, int&nbsp;*&nbsp;errorColumn = 0 )</li>
<li class=fn>bool <a href="#setContent-4"><b>setContent</b></a> ( TQIODevice&nbsp;*&nbsp;dev, bool&nbsp;namespaceProcessing, TQString&nbsp;*&nbsp;errorMsg = 0, int&nbsp;*&nbsp;errorLine = 0, int&nbsp;*&nbsp;errorColumn = 0 )</li>
<li class=fn>bool <a href="#setContent-5"><b>setContent</b></a> ( const&nbsp;TQCString&nbsp;&amp;&nbsp;buffer, TQString&nbsp;*&nbsp;errorMsg = 0, int&nbsp;*&nbsp;errorLine = 0, int&nbsp;*&nbsp;errorColumn = 0 )</li>
<li class=fn>bool <a href="#setContent-6"><b>setContent</b></a> ( const&nbsp;TQByteArray&nbsp;&amp;&nbsp;buffer, TQString&nbsp;*&nbsp;errorMsg = 0, int&nbsp;*&nbsp;errorLine = 0, int&nbsp;*&nbsp;errorColumn = 0 )</li>
<li class=fn>bool <a href="#setContent-7"><b>setContent</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;text, TQString&nbsp;*&nbsp;errorMsg = 0, int&nbsp;*&nbsp;errorLine = 0, int&nbsp;*&nbsp;errorColumn = 0 )</li>
<li class=fn>bool <a href="#setContent-8"><b>setContent</b></a> ( TQIODevice&nbsp;*&nbsp;dev, TQString&nbsp;*&nbsp;errorMsg = 0, int&nbsp;*&nbsp;errorLine = 0, int&nbsp;*&nbsp;errorColumn = 0 )</li>
<li class=fn>bool <a href="#setContent-9"><b>setContent</b></a> ( TQXmlInputSource&nbsp;*&nbsp;source, TQXmlReader&nbsp;*&nbsp;reader, TQString&nbsp;*&nbsp;errorMsg = 0, int&nbsp;*&nbsp;errorLine = 0, int&nbsp;*&nbsp;errorColumn = 0 )</li>
<li class=fn>virtual TQDomNode::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>TQString <a href="#toString"><b>toString</b></a> () const</li>
<li class=fn>TQString <a href="#toString-2"><b>toString</b></a> ( int&nbsp;indent ) const</li>
<li class=fn>TQCString <a href="#toCString"><b>toCString</b></a> () const</li>
<li class=fn>TQCString <a href="#toCString-2"><b>toCString</b></a> ( int&nbsp;indent ) const</li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>
The TQDomDocument class represents an XML document.
<p>
<p> 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.
<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="tqdomnode.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="tqdomnode.html">TQDomNode</a>, TQDomDocument, <a href="tqdomelement.html">TQDomElement</a> and <a href="tqdomtext.html">TQDomText</a>.
<p> The parsed XML is represented internally by a tree of objects that
can be accessed using the various TQDom classes. All TQDom classes
only <em>reference</em> 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.
<p> 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.
<p> The TQDomDocument 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 TQDom classes are typically used as follows:
<pre>
TQDomDocument doc( "mydocument" );
<a href="tqfile.html">TQFile</a> file( "mydocument.xml" );
if ( !file.<a href="tqfile.html#open">open</a>( <a href="tqfile.html#open">IO_ReadOnly</a> ) )
return;
if ( !doc.<a href="#setContent">setContent</a>( &amp;file ) ) {
file.<a href="tqfile.html#close">close</a>();
return;
}
file.<a href="tqfile.html#close">close</a>();
// print out the element names of all elements that are direct children
// of the outermost element.
<a href="tqdomelement.html">TQDomElement</a> docElem = doc.<a href="#documentElement">documentElement</a>();
<a href="tqdomnode.html">TQDomNode</a> n = docElem.<a href="tqdomnode.html#firstChild">firstChild</a>();
while( !n.<a href="tqdomnode.html#isNull">isNull</a>() ) {
<a href="tqdomelement.html">TQDomElement</a> e = n.<a href="tqdomnode.html#toElement">toElement</a>(); // try to convert the node to an element.
if( !e.<a href="tqdomnode.html#isNull">isNull</a>() ) {
cout &lt;&lt; e.<a href="tqdomelement.html#tagName">tagName</a>() &lt;&lt; endl; // the node really is an element.
}
n = n.<a href="tqdomnode.html#nextSibling">nextSibling</a>();
}
// Here we append a new element to the end of the document
<a href="tqdomelement.html">TQDomElement</a> elem = doc.<a href="#createElement">createElement</a>( "img" );
elem.<a href="tqdomelement.html#setAttribute">setAttribute</a>( "src", "myimage.png" );
docElem.<a href="tqdomnode.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>
TQDomDocument doc( "MyML" );
<a href="tqdomelement.html">TQDomElement</a> root = doc.<a href="#createElement">createElement</a>( "MyML" );
doc.<a href="tqdomnode.html#appendChild">appendChild</a>( root );
<a href="tqdomelement.html">TQDomElement</a> tag = doc.<a href="#createElement">createElement</a>( "Greeting" );
root.<a href="tqdomnode.html#appendChild">appendChild</a>( tag );
<a href="tqdomtext.html">TQDomText</a> t = doc.<a href="#createTextNode">createTextNode</a>( "Hello World" );
tag.<a href="tqdomnode.html#appendChild">appendChild</a>( t );
<a href="tqstring.html">TQString</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
TQDomDocument documentation.
<p>See also <a href="xml-tools.html">XML</a>.
<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="TQDomDocument"></a>TQDomDocument::TQDomDocument ()
</h3>
Constructs an empty document.
<h3 class=fn>explicit <a name="TQDomDocument-2"></a>TQDomDocument::TQDomDocument ( const&nbsp;<a href="tqstring.html">TQString</a>&nbsp;&amp;&nbsp;name )
</h3>
Creates a document and sets the name of the document type to <em>name</em>.
<h3 class=fn>explicit <a name="TQDomDocument-3"></a>TQDomDocument::TQDomDocument ( const&nbsp;<a href="tqdomdocumenttype.html">TQDomDocumentType</a>&nbsp;&amp;&nbsp;doctype )
</h3>
Creates a document with the document type <em>doctype</em>.
<p> <p>See also <a href="tqdomimplementation.html#createDocumentType">TQDomImplementation::createDocumentType</a>().
<h3 class=fn><a name="TQDomDocument-4"></a>TQDomDocument::TQDomDocument ( const&nbsp;<a href="tqdomdocument.html">TQDomDocument</a>&nbsp;&amp;&nbsp;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="tqdomnode.html#cloneNode">cloneNode</a>().
<h3 class=fn><a name="~TQDomDocument"></a>TQDomDocument::~TQDomDocument ()
</h3>
Destroys the object and frees its resources.
<h3 class=fn><a href="tqdomattr.html">TQDomAttr</a> <a name="createAttribute"></a>TQDomDocument::createAttribute ( const&nbsp;<a href="tqstring.html">TQString</a>&nbsp;&amp;&nbsp;name )
</h3>
Creates a new attribute called <em>name</em> that can be inserted into
an element, e.g. using <a href="tqdomelement.html#setAttributeNode">TQDomElement::setAttributeNode</a>().
<p> <p>See also <a href="#createAttributeNS">createAttributeNS</a>().
<h3 class=fn><a href="tqdomattr.html">TQDomAttr</a> <a name="createAttributeNS"></a>TQDomDocument::createAttributeNS ( const&nbsp;<a href="tqstring.html">TQString</a>&nbsp;&amp;&nbsp;nsURI, const&nbsp;<a href="tqstring.html">TQString</a>&nbsp;&amp;&nbsp;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="tqdomnode.html#prefix">TQDomNode::prefix</a>() and <a href="tqdomnode.html#localName">TQDomNode::localName</a>() to appropriate values
(depending on <em>qName</em>).
<p> <p>See also <a href="#createAttribute">createAttribute</a>().
<h3 class=fn><a href="tqdomcdatasection.html">TQDomCDATASection</a> <a name="createCDATASection"></a>TQDomDocument::createCDATASection ( const&nbsp;<a href="tqstring.html">TQString</a>&nbsp;&amp;&nbsp;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="tqdomnode.html#appendChild">TQDomNode::appendChild</a>().
<p> <p>See also <a href="tqdomnode.html#appendChild">TQDomNode::appendChild</a>(), <a href="tqdomnode.html#insertBefore">TQDomNode::insertBefore</a>(), and <a href="tqdomnode.html#insertAfter">TQDomNode::insertAfter</a>().
<h3 class=fn><a href="tqdomcomment.html">TQDomComment</a> <a name="createComment"></a>TQDomDocument::createComment ( const&nbsp;<a href="tqstring.html">TQString</a>&nbsp;&amp;&nbsp;value )
</h3>
Creates a new comment for the string <em>value</em> that can be inserted
into the document, e.g. using <a href="tqdomnode.html#appendChild">TQDomNode::appendChild</a>().
<p> <p>See also <a href="tqdomnode.html#appendChild">TQDomNode::appendChild</a>(), <a href="tqdomnode.html#insertBefore">TQDomNode::insertBefore</a>(), and <a href="tqdomnode.html#insertAfter">TQDomNode::insertAfter</a>().
<h3 class=fn><a href="tqdomdocumentfragment.html">TQDomDocumentFragment</a> <a name="createDocumentFragment"></a>TQDomDocument::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="tqdomelement.html">TQDomElement</a> <a name="createElement"></a>TQDomDocument::createElement ( const&nbsp;<a href="tqstring.html">TQString</a>&nbsp;&amp;&nbsp;tagName )
</h3>
Creates a new element called <em>tagName</em> that can be inserted into
the DOM tree, e.g. using <a href="tqdomnode.html#appendChild">TQDomNode::appendChild</a>().
<p> <p>See also <a href="#createElementNS">createElementNS</a>(), <a href="tqdomnode.html#appendChild">TQDomNode::appendChild</a>(), <a href="tqdomnode.html#insertBefore">TQDomNode::insertBefore</a>(), and <a href="tqdomnode.html#insertAfter">TQDomNode::insertAfter</a>().
<h3 class=fn><a href="tqdomelement.html">TQDomElement</a> <a name="createElementNS"></a>TQDomDocument::createElementNS ( const&nbsp;<a href="tqstring.html">TQString</a>&nbsp;&amp;&nbsp;nsURI, const&nbsp;<a href="tqstring.html">TQString</a>&nbsp;&amp;&nbsp;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="tqdomnode.html#prefix">TQDomNode::prefix</a>() and <a href="tqdomnode.html#localName">TQDomNode::localName</a>() to appropriate values
(depending on <em>qName</em>).
<p> <p>See also <a href="#createElement">createElement</a>().
<h3 class=fn><a href="tqdomentityreference.html">TQDomEntityReference</a> <a name="createEntityReference"></a>TQDomDocument::createEntityReference ( const&nbsp;<a href="tqstring.html">TQString</a>&nbsp;&amp;&nbsp;name )
</h3>
Creates a new entity reference called <em>name</em> that can be inserted
into the document, e.g. using <a href="tqdomnode.html#appendChild">TQDomNode::appendChild</a>().
<p> <p>See also <a href="tqdomnode.html#appendChild">TQDomNode::appendChild</a>(), <a href="tqdomnode.html#insertBefore">TQDomNode::insertBefore</a>(), and <a href="tqdomnode.html#insertAfter">TQDomNode::insertAfter</a>().
<h3 class=fn><a href="tqdomprocessinginstruction.html">TQDomProcessingInstruction</a> <a name="createProcessingInstruction"></a>TQDomDocument::createProcessingInstruction ( const&nbsp;<a href="tqstring.html">TQString</a>&nbsp;&amp;&nbsp;target, const&nbsp;<a href="tqstring.html">TQString</a>&nbsp;&amp;&nbsp;data )
</h3>
Creates a new processing instruction that can be inserted into the
document, e.g. using <a href="tqdomnode.html#appendChild">TQDomNode::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="tqdomnode.html#appendChild">TQDomNode::appendChild</a>(), <a href="tqdomnode.html#insertBefore">TQDomNode::insertBefore</a>(), and <a href="tqdomnode.html#insertAfter">TQDomNode::insertAfter</a>().
<h3 class=fn><a href="tqdomtext.html">TQDomText</a> <a name="createTextNode"></a>TQDomDocument::createTextNode ( const&nbsp;<a href="tqstring.html">TQString</a>&nbsp;&amp;&nbsp;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="tqdomnode.html#appendChild">TQDomNode::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="tqdomnode.html#appendChild">TQDomNode::appendChild</a>(), <a href="tqdomnode.html#insertBefore">TQDomNode::insertBefore</a>(), and <a href="tqdomnode.html#insertAfter">TQDomNode::insertAfter</a>().
<h3 class=fn><a href="tqdomdocumenttype.html">TQDomDocumentType</a> <a name="doctype"></a>TQDomDocument::doctype () const
</h3>
Returns the document type of this document.
<h3 class=fn><a href="tqdomelement.html">TQDomElement</a> <a name="documentElement"></a>TQDomDocument::documentElement () const
</h3>
Returns the root element of the document.
<h3 class=fn><a href="tqdomelement.html">TQDomElement</a> <a name="elementById"></a>TQDomDocument::elementById ( const&nbsp;<a href="tqstring.html">TQString</a>&nbsp;&amp;&nbsp;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="tqdomnode.html#isNull">null element</a>.
<p> Since the TQDomClasses do not know which attributes are element
IDs, this function returns always a <a href="tqdomnode.html#isNull">null
element</a>. This may change in a future version.
<h3 class=fn><a href="tqdomnodelist.html">TQDomNodeList</a> <a name="elementsByTagName"></a>TQDomDocument::elementsByTagName ( const&nbsp;<a href="tqstring.html">TQString</a>&nbsp;&amp;&nbsp;tagname ) const
</h3>
Returns a <a href="tqdomnodelist.html">TQDomNodeList</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="tqdomelement.html#elementsByTagName">TQDomElement::elementsByTagName</a>().
<h3 class=fn><a href="tqdomnodelist.html">TQDomNodeList</a> <a name="elementsByTagNameNS"></a>TQDomDocument::elementsByTagNameNS ( const&nbsp;<a href="tqstring.html">TQString</a>&nbsp;&amp;&nbsp;nsURI, const&nbsp;<a href="tqstring.html">TQString</a>&nbsp;&amp;&nbsp;localName )
</h3>
Returns a <a href="tqdomnodelist.html">TQDomNodeList</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="tqdomelement.html#elementsByTagNameNS">TQDomElement::elementsByTagNameNS</a>().
<h3 class=fn><a href="tqdomimplementation.html">TQDomImplementation</a> <a name="implementation"></a>TQDomDocument::implementation () const
</h3>
Returns a <a href="tqdomimplementation.html">TQDomImplementation</a> object.
<h3 class=fn><a href="tqdomnode.html">TQDomNode</a> <a name="importNode"></a>TQDomDocument::importNode ( const&nbsp;<a href="tqdomnode.html">TQDomNode</a>&nbsp;&amp;&nbsp;importedNode, bool&nbsp;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 TQDomDocument and <a href="tqdomdocumenttype.html">TQDomDocumentType</a> nodes. In those cases
this function returns a <a href="tqdomnode.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="tqdomattr.html">TQDomAttr</a> and <a href="tqdomentityreference.html">TQDomEntityReference</a> nodes, since the descendents of
TQDomAttr nodes are always imported and those of
TQDomEntityReference 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">TQDomAttr
<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">TQDomDocument
<td valign="top">Document nodes cannot be imported.
<tr bgcolor="#f0f0f0"> <td valign="top">TQDomDocumentFragment
<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">TQDomDocumentType
<td valign="top">Document type nodes cannot be imported.
<tr bgcolor="#f0f0f0"> <td valign="top">TQDomElement
<td valign="top">Attributes for which <a href="tqdomattr.html#specified">TQDomAttr::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">TQDomEntity
<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">TQDomEntityReference
<td valign="top">Descendents of entity reference nodes are never imported:
<em>deep</em> has no effect.
<tr bgcolor="#d0d0d0"> <td valign="top">TQDomNotation
<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">TQDomProcessingInstruction
<td valign="top">The target and value of the processing instruction is
copied to the new node.
<tr bgcolor="#d0d0d0"> <td valign="top">TQDomText
<td valign="top">The text is copied to the new node.
<tr bgcolor="#f0f0f0"> <td valign="top">TQDomCDATASection
<td valign="top">The text is copied to the new node.
<tr bgcolor="#d0d0d0"> <td valign="top">TQDomComment
<td valign="top">The text is copied to the new node.
</table></center>
<p> <p>See also <a href="tqdomelement.html#setAttribute">TQDomElement::setAttribute</a>(), <a href="tqdomnode.html#insertBefore">TQDomNode::insertBefore</a>(), <a href="tqdomnode.html#insertAfter">TQDomNode::insertAfter</a>(), <a href="tqdomnode.html#replaceChild">TQDomNode::replaceChild</a>(), <a href="tqdomnode.html#removeChild">TQDomNode::removeChild</a>(), and <a href="tqdomnode.html#appendChild">TQDomNode::appendChild</a>().
<h3 class=fn>bool <a name="isDocument"></a>TQDomDocument::isDocument () const<tt> [virtual]</tt>
</h3>
Returns TRUE.
<p>Reimplemented from <a href="tqdomnode.html#isDocument">TQDomNode</a>.
<h3 class=fn><a href="tqdomnode.html#NodeType-enum">TQDomNode::NodeType</a> <a name="nodeType"></a>TQDomDocument::nodeType () const<tt> [virtual]</tt>
</h3>
Returns <a href="tqdomnode.html#NodeType-enum">DocumentNode</a>.
<p>Reimplemented from <a href="tqdomnode.html#nodeType">TQDomNode</a>.
<h3 class=fn><a href="tqdomdocument.html">TQDomDocument</a>&nbsp;&amp; <a name="operator-eq"></a>TQDomDocument::operator= ( const&nbsp;<a href="tqdomdocument.html">TQDomDocument</a>&nbsp;&amp;&nbsp;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="tqdomnode.html#cloneNode">cloneNode</a>().
<h3 class=fn>bool <a name="setContent"></a>TQDomDocument::setContent ( const&nbsp;<a href="tqbytearray.html">TQByteArray</a>&nbsp;&amp;&nbsp;buffer, bool&nbsp;namespaceProcessing, <a href="tqstring.html">TQString</a>&nbsp;*&nbsp;errorMsg = 0, int&nbsp;*&nbsp;errorLine = 0, int&nbsp;*&nbsp;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="tqdomnode.html#prefix">TQDomNode::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
TQDomNode::prefix(), <a href="tqdomnode.html#localName">TQDomNode::localName</a>() and
<a href="tqdomnode.html#namespaceURI">TQDomNode::namespaceURI</a>() return <a href="tqstring.html#TQString-null">TQString::null</a>.
<p> <p>See also <a href="tqdomnode.html#namespaceURI">TQDomNode::namespaceURI</a>(), <a href="tqdomnode.html#localName">TQDomNode::localName</a>(), <a href="tqdomnode.html#prefix">TQDomNode::prefix</a>(), <a href="tqstring.html#isNull">TQString::isNull</a>(), and <a href="tqstring.html#isEmpty">TQString::isEmpty</a>().
<h3 class=fn>bool <a name="setContent-2"></a>TQDomDocument::setContent ( const&nbsp;<a href="tqcstring.html">TQCString</a>&nbsp;&amp;&nbsp;buffer, bool&nbsp;namespaceProcessing, <a href="tqstring.html">TQString</a>&nbsp;*&nbsp;errorMsg = 0, int&nbsp;*&nbsp;errorLine = 0, int&nbsp;*&nbsp;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>TQDomDocument::setContent ( const&nbsp;<a href="tqstring.html">TQString</a>&nbsp;&amp;&nbsp;text, bool&nbsp;namespaceProcessing, <a href="tqstring.html">TQString</a>&nbsp;*&nbsp;errorMsg = 0, int&nbsp;*&nbsp;errorLine = 0, int&nbsp;*&nbsp;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>TQDomDocument::setContent ( <a href="tqiodevice.html">TQIODevice</a>&nbsp;*&nbsp;dev, bool&nbsp;namespaceProcessing, <a href="tqstring.html">TQString</a>&nbsp;*&nbsp;errorMsg = 0, int&nbsp;*&nbsp;errorLine = 0, int&nbsp;*&nbsp;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>TQDomDocument::setContent ( const&nbsp;<a href="tqcstring.html">TQCString</a>&nbsp;&amp;&nbsp;buffer, <a href="tqstring.html">TQString</a>&nbsp;*&nbsp;errorMsg = 0, int&nbsp;*&nbsp;errorLine = 0, int&nbsp;*&nbsp;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>TQDomDocument::setContent ( const&nbsp;<a href="tqbytearray.html">TQByteArray</a>&nbsp;&amp;&nbsp;buffer, <a href="tqstring.html">TQString</a>&nbsp;*&nbsp;errorMsg = 0, int&nbsp;*&nbsp;errorLine = 0, int&nbsp;*&nbsp;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>TQDomDocument::setContent ( const&nbsp;<a href="tqstring.html">TQString</a>&nbsp;&amp;&nbsp;text, <a href="tqstring.html">TQString</a>&nbsp;*&nbsp;errorMsg = 0, int&nbsp;*&nbsp;errorLine = 0, int&nbsp;*&nbsp;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>TQDomDocument::setContent ( <a href="tqiodevice.html">TQIODevice</a>&nbsp;*&nbsp;dev, <a href="tqstring.html">TQString</a>&nbsp;*&nbsp;errorMsg = 0, int&nbsp;*&nbsp;errorLine = 0, int&nbsp;*&nbsp;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>TQDomDocument::setContent ( <a href="tqxmlinputsource.html">TQXmlInputSource</a>&nbsp;*&nbsp;source, <a href="tqxmlreader.html">TQXmlReader</a>&nbsp;*&nbsp;reader, <a href="tqstring.html">TQString</a>&nbsp;*&nbsp;errorMsg = 0, int&nbsp;*&nbsp;errorLine = 0, int&nbsp;*&nbsp;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="tqxmlinputsource.html">TQXmlInputSource</a> <em>source</em> and
parses it with the <a href="tqxmlreader.html">TQXmlReader</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="tqxmlsimplereader.html">TQXmlSimpleReader</a>.
<h3 class=fn><a href="tqcstring.html">TQCString</a> <a name="toCString"></a>TQDomDocument::toCString () const
</h3>
Converts the parsed document back to its textual representation
and returns a <a href="tqcstring.html">TQCString</a> for that is encoded in UTF-8.
<p> <p>See also <a href="#toString">toString</a>().
<h3 class=fn><a href="tqcstring.html">TQCString</a> <a name="toCString-2"></a>TQDomDocument::toCString ( int&nbsp;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="tqstring.html">TQString</a> <a name="toString"></a>TQDomDocument::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="tqstring.html">TQString</a> <a name="toString-2"></a>TQDomDocument::toString ( int&nbsp;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">TQt toolkit</a>.
Copyright &copy; 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 &copy; 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>TQt 3.3.8</div>
</table></div></address></body>
</html>