<class name="QDomElement" doc="/** <p>The <a href="QDomElement.html#QDomElement(com.trolltech.qt.xml.QDomElement)"><tt>QDomElement</tt></a> class represents one element in the DOM tree.</p> <p>Elements have a <a href="QDomElement.html#tagName()"><tt>tagName</tt></a> and zero or more attributes associated with them. The tag name can be changed with <a href="QDomElement.html#setTagName(java.lang.String)"><tt>setTagName</tt></a>.</p> <p>Element attributes are represented by <a href="QDomAttr.html"><tt>QDomAttr</tt></a> objects that can be queried using the <a href="QDomElement.html#attribute(java.lang.String, java.lang.String)"><tt>attribute</tt></a> and <a href="QDomElement.html#attributeNode(java.lang.String)"><tt>attributeNode</tt></a> functions. You can set attributes with the <a href="QDomElement.html#setAttribute(java.lang.String, long)"><tt>setAttribute</tt></a> and <a href="QDomElement.html#setAttributeNode(com.trolltech.qt.xml.QDomAttr)"><tt>setAttributeNode</tt></a> functions. Attributes can be removed with <a href="QDomElement.html#removeAttribute(java.lang.String)"><tt>removeAttribute</tt></a>. There are namespace-aware equivalents to these functions, i.e&#x2e; <a href="QDomElement.html#setAttributeNS(java.lang.String, java.lang.String, long)"><tt>setAttributeNS</tt></a>, <a href="QDomElement.html#setAttributeNodeNS(com.trolltech.qt.xml.QDomAttr)"><tt>setAttributeNodeNS</tt></a> and <a href="QDomElement.html#removeAttributeNS(java.lang.String, java.lang.String)"><tt>removeAttributeNS</tt></a>.</p> <p>If you want to access the text of a node use <a href="QDomElement.html#text()"><tt>text</tt></a>, e.g&#x2e;</p> <pre> QDomElement e = <span class="comment">//...</span> <span class="comment"> //...</span> QString s = e.text()</pre> <p>The <a href="QDomElement.html#text()"><tt>text</tt></a> function operates recursively to find the text (since not all elements contain text). If you want to find all the text in all of a node's children, iterate over the children looking for <a href="QDomText.html"><tt>QDomText</tt></a> nodes, e.g&#x2e;</p> <pre> QString text; QDomElement element = doc.documentElement(); for(QDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling()) { QDomText t = n.toText(); if (!t.isNull()) text += t.data(); }</pre> <p>Note that we attempt to convert each node to a text node and use <a href="QDomElement.html#text()"><tt>text</tt></a> rather than using <a href="QDomNode.html#firstChild()"><tt>firstChild</tt></a>.<a href="QDomNode.html#toText()"><tt>toText</tt></a>.data() or n.<a href="QDomNode.html#toText()"><tt>toText</tt></a>.data() directly on the node, because the node may not be a text element.</p> <p>You can get a list of all the decendents of an element which have a specified tag name with <a href="QDomElement.html#elementsByTagName(java.lang.String)"><tt>elementsByTagName</tt></a> or <a href="QDomElement.html#elementsByTagNameNS(java.lang.String, java.lang.String)"><tt>elementsByTagNameNS</tt></a>.</p> <p>To browse the elements of a dom document use <a href="QDomNode.html#firstChildElement(java.lang.String)"><tt>firstChildElement</tt></a>, <a href="QDomNode.html#lastChildElement(java.lang.String)"><tt>lastChildElement</tt></a>, <a href="QDomNode.html#nextSiblingElement(java.lang.String)"><tt>nextSiblingElement</tt></a> and <a href="QDomNode.html#previousSiblingElement(java.lang.String)"><tt>previousSiblingElement</tt></a>. For example, to iterate over all child elements called &quot;entry&quot; in a root element called &quot;database&quot;, you can use:</p> <pre> QDomDocument doc = <span class="comment">// ...</span> QDomElement root = doc.firstChildElement(&quot;database&quot;); QDomElement elt = root.firstChildElement(&quot;entry&quot;); for (; !elt.isNull(); elt = elt.nextSiblingElelement(&quot;entry&quot;)) { <span class="comment">// ...</span> }</pre> <p>For further information about the Document Object Model see <a href="http://www.w3.org/TR/REC-DOM-Level-1/">Level 1</tt></a> and <a href="http://www.w3.org/TR/DOM-Level-2-Core/">Level 2 Core</tt></a>. For a more general introduction of the DOM implementation see the <a href="QDomDocument.html"><tt>QDomDocument</tt></a> documentation.</p> */"> <method name="public QDomElement()" doc="/** <p>Constructs an empty element. Use the QDomDocument::createElement() function to construct elements with content.</p> */"/> <method name="public QDomElement(com.trolltech.qt.xml.QDomElement x)" doc="/** <p>Constructs a copy of <tt>x</tt>.</p> <p>The data of the copy is shared (shallow copy): modifying one node will also change the other. If you want to make a deep copy, use <a href="QDomNode.html#cloneNode(boolean)"><tt>cloneNode</tt></a>.</p> */"/> <method name="public final java.lang.String attribute(java.lang.String name, java.lang.String defValue)" doc="/** <p>Returns the attribute called <tt>name</tt>. If the attribute does not exist <tt>defValue</tt> is returned.</p> @see <a href="QDomElement.html#setAttribute(java.lang.String, long)"><tt>setAttribute</tt></a> @see <a href="QDomElement.html#attributeNode(java.lang.String)"><tt>attributeNode</tt></a> @see <a href="QDomElement.html#setAttributeNode(com.trolltech.qt.xml.QDomAttr)"><tt>setAttributeNode</tt></a> @see <a href="QDomElement.html#attributeNS(java.lang.String, java.lang.String, java.lang.String)"><tt>attributeNS</tt></a> */"/> <method name="public final java.lang.String attribute(java.lang.String name)" doc="/** <p>Equivalent to <a href="QDomElement.html#attribute(java.lang.String, java.lang.String)">attribute</tt></a>(<tt>name</tt>, QString()). */"/> <method name="public final java.lang.String attributeNS(java.lang.String nsURI, java.lang.String localName, java.lang.String defValue)" doc="/** <p>Returns the attribute with the local name <tt>localName</tt> and the namespace URI <tt>nsURI</tt>. If the attribute does not exist <tt>defValue</tt> is returned.</p> @see <a href="QDomElement.html#setAttributeNS(java.lang.String, java.lang.String, long)"><tt>setAttributeNS</tt></a> @see <a href="QDomElement.html#attributeNodeNS(java.lang.String, java.lang.String)"><tt>attributeNodeNS</tt></a> @see <a href="QDomElement.html#setAttributeNodeNS(com.trolltech.qt.xml.QDomAttr)"><tt>setAttributeNodeNS</tt></a> @see <a href="QDomElement.html#attribute(java.lang.String, java.lang.String)"><tt>attribute</tt></a> */"/> <method name="public final java.lang.String attributeNS(java.lang.String nsURI, java.lang.String localName)" doc="/** <p>Equivalent to <a href="QDomElement.html#attributeNS(java.lang.String, java.lang.String, java.lang.String)"><tt>attributeNS</tt></a>(<tt>nsURI</tt>, <tt>localName</tt>, QString()). */"/> <method name="public final com.trolltech.qt.xml.QDomAttr attributeNode(java.lang.String name)" doc="/** <p>Returns the <a href="QDomAttr.html"><tt>QDomAttr</tt></a> object that corresponds to the attribute called <tt>name</tt>. If no such attribute exists a null attribute</tt> is returned.</p> @see <a href="QDomElement.html#setAttributeNode(com.trolltech.qt.xml.QDomAttr)"><tt>setAttributeNode</tt></a> @see <a href="QDomElement.html#attribute(java.lang.String, java.lang.String)"><tt>attribute</tt></a> @see <a href="QDomElement.html#setAttribute(java.lang.String, long)"><tt>setAttribute</tt></a> @see <a href="QDomElement.html#attributeNodeNS(java.lang.String, java.lang.String)"><tt>attributeNodeNS</tt></a> */"/> <method name="public final com.trolltech.qt.xml.QDomAttr attributeNodeNS(java.lang.String nsURI, java.lang.String localName)" doc="/** <p>Returns the <a href="QDomAttr.html"><tt>QDomAttr</tt></a> object that corresponds to the attribute with the local name <tt>localName</tt> and the namespace URI <tt>nsURI</tt>. If no such attribute exists a null attribute</tt> is returned.</p> @see <a href="QDomElement.html#setAttributeNodeNS(com.trolltech.qt.xml.QDomAttr)"><tt>setAttributeNodeNS</tt></a> @see <a href="QDomElement.html#setAttributeNode(com.trolltech.qt.xml.QDomAttr)"><tt>setAttributeNode</tt></a> @see <a href="QDomElement.html#attribute(java.lang.String, java.lang.String)"><tt>attribute</tt></a> @see <a href="QDomElement.html#setAttribute(java.lang.String, long)"><tt>setAttribute</tt></a> */"/> <method name="public final com.trolltech.qt.xml.QDomNamedNodeMap attributes()" doc="/** <p>Returns a <a href="QDomNamedNodeMap.html"><tt>QDomNamedNodeMap</tt></a> containing all this element's attributes.</p> @see <a href="QDomElement.html#attribute(java.lang.String, java.lang.String)"><tt>attribute</tt></a> @see <a href="QDomElement.html#setAttribute(java.lang.String, long)"><tt>setAttribute</tt></a> @see <a href="QDomElement.html#attributeNode(java.lang.String)"><tt>attributeNode</tt></a> @see <a href="QDomElement.html#setAttributeNode(com.trolltech.qt.xml.QDomAttr)"><tt>setAttributeNode</tt></a> */"/> <method name="public final com.trolltech.qt.xml.QDomNodeList elementsByTagName(java.lang.String tagname)" doc="/** <p>Returns a <a href="QDomNodeList.html"><tt>QDomNodeList</tt></a> containing all descendent elements of this element that are called <tt>tagname</tt>. The order they are in the node list is the order they are encountered in a preorder traversal of the element tree.</p> @see <a href="QDomElement.html#elementsByTagNameNS(java.lang.String, java.lang.String)"><tt>elementsByTagNameNS</tt></a> @see <tt>QDomDocument::elementsByTagName</tt> */"/> <method name="public final com.trolltech.qt.xml.QDomNodeList elementsByTagNameNS(java.lang.String nsURI, java.lang.String localName)" doc="/** <p>Returns a <a href="QDomNodeList.html"><tt>QDomNodeList</tt></a> containing all the descendent elements of this element with the local name <tt>localName</tt> and the namespace URI <tt>nsURI</tt>. The order they are in the node list is the order they are encountered in a preorder traversal of the element tree.</p> @see <a href="QDomElement.html#elementsByTagName(java.lang.String)"><tt>elementsByTagName</tt></a> @see <tt>QDomDocument::elementsByTagNameNS</tt> */"/> <method name="public final boolean hasAttribute(java.lang.String name)" doc="/** <p>Returns true if this element has an attribute called <tt>name</tt>; otherwise returns false.</p> <p><b>Note:</b> This function does not take the presence of namespaces into account. As a result, the specified name will be tested against fully-qualified attribute names that include any namespace prefixes that may be present.</p> <p>Use <a href="QDomElement.html#hasAttributeNS(java.lang.String, java.lang.String)"><tt>hasAttributeNS</tt></a> to explicitly test for attributes with specific namespaces and names.</p> */"/> <method name="public final boolean hasAttributeNS(java.lang.String nsURI, java.lang.String localName)" doc="/** <p>Returns true if this element has an attribute with the local name <tt>localName</tt> and the namespace URI <tt>nsURI</tt>; otherwise returns false.</p> */"/> <method name="public final void removeAttribute(java.lang.String name)" doc="/** <p>Removes the attribute called name <tt>name</tt> from this element.</p> @see <a href="QDomElement.html#setAttribute(java.lang.String, long)"><tt>setAttribute</tt></a> @see <a href="QDomElement.html#attribute(java.lang.String, java.lang.String)"><tt>attribute</tt></a> @see <a href="QDomElement.html#removeAttributeNS(java.lang.String, java.lang.String)"><tt>removeAttributeNS</tt></a> */"/> <method name="public final void removeAttributeNS(java.lang.String nsURI, java.lang.String localName)" doc="/** <p>Removes the attribute with the local name <tt>localName</tt> and the namespace URI <tt>nsURI</tt> from this element.</p> @see <a href="QDomElement.html#setAttributeNS(java.lang.String, java.lang.String, long)"><tt>setAttributeNS</tt></a> @see <a href="QDomElement.html#attributeNS(java.lang.String, java.lang.String, java.lang.String)"><tt>attributeNS</tt></a> @see <a href="QDomElement.html#removeAttribute(java.lang.String)"><tt>removeAttribute</tt></a> */"/> <method name="public final com.trolltech.qt.xml.QDomAttr removeAttributeNode(com.trolltech.qt.xml.QDomAttr oldAttr)" doc="/** <p>Removes the attribute <tt>oldAttr</tt> from the element and returns it.</p> @see <a href="QDomElement.html#attributeNode(java.lang.String)"><tt>attributeNode</tt></a> @see <a href="QDomElement.html#setAttributeNode(com.trolltech.qt.xml.QDomAttr)"><tt>setAttributeNode</tt></a> */"/> <method name="public final void setAttribute(java.lang.String name, int value)"/> <method name="public final void setAttribute(java.lang.String name, double value)"/> <method name="public final void setAttribute(java.lang.String name, java.lang.String value)" doc="/** <p>Adds an attribute called <tt>name</tt> with value <tt>value</tt>. If an attribute with the same name exists, its value is replaced by <tt>value</tt>.</p> @see <a href="QDomElement.html#attribute(java.lang.String, java.lang.String)"><tt>attribute</tt></a> @see <a href="QDomElement.html#setAttributeNode(com.trolltech.qt.xml.QDomAttr)"><tt>setAttributeNode</tt></a> @see <a href="QDomElement.html#setAttributeNS(java.lang.String, java.lang.String, long)"><tt>setAttributeNS</tt></a> */"/> <method name="public final void setAttribute(java.lang.String name, float value)"/> <method name="public final void setAttribute(java.lang.String name, long value)"/> <method name="public final void setAttributeNS(java.lang.String nsURI, java.lang.String qName, int value)"/> <method name="public final void setAttributeNS(java.lang.String nsURI, java.lang.String qName, java.lang.String value)" doc="/** <p>Adds an attribute with the qualified name <tt>qName</tt> and the namespace URI <tt>nsURI</tt> with the value <tt>value</tt>. If an attribute with the same local name and namespace URI exists, its prefix is replaced by the prefix of <tt>qName</tt> and its value is repaced by <tt>value</tt>.</p> <p>Although <tt>qName</tt> is the qualified name, the local name is used to decide if an existing attribute's value should be replaced.</p> @see <a href="QDomElement.html#attributeNS(java.lang.String, java.lang.String, java.lang.String)"><tt>attributeNS</tt></a> @see <a href="QDomElement.html#setAttributeNodeNS(com.trolltech.qt.xml.QDomAttr)"><tt>setAttributeNodeNS</tt></a> @see <a href="QDomElement.html#setAttribute(java.lang.String, long)"><tt>setAttribute</tt></a> */"/> <method name="public final void setAttributeNS(java.lang.String nsURI, java.lang.String qName, double value)"/> <method name="public final void setAttributeNS(java.lang.String nsURI, java.lang.String qName, long value)"/> <method name="public final com.trolltech.qt.xml.QDomAttr setAttributeNode(com.trolltech.qt.xml.QDomAttr newAttr)" doc="/** <p>Adds the attribute <tt>newAttr</tt> to this element.</p> <p>If the element has another attribute that has the same name as <tt>newAttr</tt>, this function replaces that attribute and returns it; otherwise the function returns a null attribute</tt>.</p> @see <a href="QDomElement.html#attributeNode(java.lang.String)"><tt>attributeNode</tt></a> @see <a href="QDomElement.html#setAttribute(java.lang.String, long)"><tt>setAttribute</tt></a> @see <a href="QDomElement.html#setAttributeNodeNS(com.trolltech.qt.xml.QDomAttr)"><tt>setAttributeNodeNS</tt></a> */"/> <method name="public final com.trolltech.qt.xml.QDomAttr setAttributeNodeNS(com.trolltech.qt.xml.QDomAttr newAttr)" doc="/** <p>Adds the attribute <tt>newAttr</tt> to this element.</p> <p>If the element has another attribute that has the same local name and namespace URI as <tt>newAttr</tt>, this function replaces that attribute and returns it; otherwise the function returns a null attribute</tt>.</p> @see <a href="QDomElement.html#attributeNodeNS(java.lang.String, java.lang.String)"><tt>attributeNodeNS</tt></a> @see <a href="QDomElement.html#setAttributeNS(java.lang.String, java.lang.String, long)"><tt>setAttributeNS</tt></a> @see <a href="QDomElement.html#setAttributeNode(com.trolltech.qt.xml.QDomAttr)"><tt>setAttributeNode</tt></a> */"/> <method name="public final void setTagName(java.lang.String name)" doc="/** <p>Sets this element's tag name to <tt>name</tt>.</p> @see <a href="QDomElement.html#tagName()"><tt>tagName</tt></a> */"/> <method name="public final java.lang.String tagName()" doc="/** <p>Returns the tag name of this element. For an XML element like this:</p> <pre> &lt;img src=&quot;myimg.png&quot;&gt;</pre> <p>the tagname would return &quot;img&quot;.</p> @see <a href="QDomElement.html#setTagName(java.lang.String)"><tt>setTagName</tt></a> */"/> <method name="public final java.lang.String text()" doc="/** <p>Returns the element's text or an empty string.</p> <p>Example:</p> <pre> &lt;h1&gt;Hello &lt;b&gt;Qt&lt;/b&gt; &lt;![CDATA[&lt;xml is cool&gt;]]&gt;&lt;/h1&gt;</pre> <p>The function <a href="QDomElement.html#text()"><tt>text</tt></a> of the <a href="QDomElement.html#QDomElement(com.trolltech.qt.xml.QDomElement)"><tt>QDomElement</tt></a> for the <tt>&lt;h1&gt;</tt> tag, will return the following text:</p> <pre> Hello Qt &amp;lt;xml is cool&amp;gt;</pre> <p>Comments are ignored by this function. It only evaluates <a href="QDomText.html"><tt>QDomText</tt></a> and <a href="QDomCDATASection.html"><tt>QDomCDATASection</tt></a> objects.</p> */"/> </class>