qdomelement.html

来自「QT 下载资料仅供参考」· HTML 代码 · 共 313 行 · 第 1/2 页

HTML
313
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><!-- /home/reggie/tmp/qt-3.0-reggie-5401/qt-x11-commercial-3.0.5/src/xml/qdom.cpp:3982 --><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>QDomElement Class</title><style type="text/css"><!--h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }a:link { color: #004faf; text-decoration: none }a:visited { color: #672967; text-decoration: none }body { background: #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>QDomElement Class Reference<br><small>[<a href="xml.html">XML module</a>]</small></h1><p>The QDomElement class represents one element in the DOM tree.<a href="#details">More...</a><p><tt>#include &lt;<a href="qdom-h.html">qdom.h</a>&gt;</tt><p>Inherits <a href="qdomnode.html">QDomNode</a>.<p><a href="qdomelement-members.html">List of all member functions.</a><h2>Public Members</h2><ul><li><div class=fn><a href="#QDomElement"><b>QDomElement</b></a> ()</div></li><li><div class=fn><a href="#QDomElement-2"><b>QDomElement</b></a> ( const&nbsp;QDomElement&nbsp;&amp;&nbsp;x )</div></li><li><div class=fn>QDomElement &amp; <a href="#operator-eq"><b>operator=</b></a> ( const&nbsp;QDomElement&nbsp;&amp;&nbsp;x )</div></li><li><div class=fn><a href="#~QDomElement"><b>~QDomElement</b></a> ()</div></li><li><div class=fn>QString <a href="#attribute"><b>attribute</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;name, const&nbsp;QString&nbsp;&amp;&nbsp;defValue = QString::null ) const</div></li><li><div class=fn>void <a href="#setAttribute"><b>setAttribute</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;name, const&nbsp;QString&nbsp;&amp;&nbsp;value )</div></li><li><div class=fn>void <a href="#setAttribute-2"><b>setAttribute</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;name, int&nbsp;value )</div></li><li><div class=fn>void <a href="#setAttribute-3"><b>setAttribute</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;name, uint&nbsp;value )</div></li><li><div class=fn>void <a href="#setAttribute-4"><b>setAttribute</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;name, double&nbsp;value )</div></li><li><div class=fn>void <a href="#removeAttribute"><b>removeAttribute</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;name )</div></li><li><div class=fn>QDomAttr <a href="#attributeNode"><b>attributeNode</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;name )</div></li><li><div class=fn>QDomAttr <a href="#setAttributeNode"><b>setAttributeNode</b></a> ( const&nbsp;QDomAttr&nbsp;&amp;&nbsp;newAttr )</div></li><li><div class=fn>QDomAttr <a href="#removeAttributeNode"><b>removeAttributeNode</b></a> ( const&nbsp;QDomAttr&nbsp;&amp;&nbsp;oldAttr )</div></li><li><div class=fn>virtual QDomNodeList <a href="#elementsByTagName"><b>elementsByTagName</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;tagname ) const</div></li><li><div class=fn>bool <a href="#hasAttribute"><b>hasAttribute</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;name ) const</div></li><li><div class=fn>QString <a href="#attributeNS"><b>attributeNS</b></a> ( const&nbsp;QString&nbsp;nsURI, const&nbsp;QString&nbsp;&amp;&nbsp;localName, const&nbsp;QString&nbsp;&amp;&nbsp;defValue ) const</div></li><li><div class=fn>void <a href="#setAttributeNS"><b>setAttributeNS</b></a> ( const&nbsp;QString&nbsp;nsURI, const&nbsp;QString&nbsp;&amp;&nbsp;qName, const&nbsp;QString&nbsp;&amp;&nbsp;value )</div></li><li><div class=fn>void <a href="#setAttributeNS-2"><b>setAttributeNS</b></a> ( const&nbsp;QString&nbsp;nsURI, const&nbsp;QString&nbsp;&amp;&nbsp;qName, int&nbsp;value )</div></li><li><div class=fn>void <a href="#setAttributeNS-3"><b>setAttributeNS</b></a> ( const&nbsp;QString&nbsp;nsURI, const&nbsp;QString&nbsp;&amp;&nbsp;qName, uint&nbsp;value )</div></li><li><div class=fn>void <a href="#setAttributeNS-4"><b>setAttributeNS</b></a> ( const&nbsp;QString&nbsp;nsURI, const&nbsp;QString&nbsp;&amp;&nbsp;qName, double&nbsp;value )</div></li><li><div class=fn>void <a href="#removeAttributeNS"><b>removeAttributeNS</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;nsURI, const&nbsp;QString&nbsp;&amp;&nbsp;localName )</div></li><li><div class=fn>QDomAttr <a href="#attributeNodeNS"><b>attributeNodeNS</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;nsURI, const&nbsp;QString&nbsp;&amp;&nbsp;localName )</div></li><li><div class=fn>QDomAttr <a href="#setAttributeNodeNS"><b>setAttributeNodeNS</b></a> ( const&nbsp;QDomAttr&nbsp;&amp;&nbsp;newAttr )</div></li><li><div class=fn>virtual QDomNodeList <a href="#elementsByTagNameNS"><b>elementsByTagNameNS</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;nsURI, const&nbsp;QString&nbsp;&amp;&nbsp;localName ) const</div></li><li><div class=fn>bool <a href="#hasAttributeNS"><b>hasAttributeNS</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;nsURI, const&nbsp;QString&nbsp;&amp;&nbsp;localName ) const</div></li><li><div class=fn>QString <a href="#tagName"><b>tagName</b></a> () const</div></li><li><div class=fn>void <a href="#setTagName"><b>setTagName</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;name )</div></li><li><div class=fn>virtual QDomNamedNodeMap <a href="#attributes"><b>attributes</b></a> () const</div></li><li><div class=fn>virtual QDomNode::NodeType <a href="#nodeType"><b>nodeType</b></a> () const</div></li><li><div class=fn>virtual bool <a href="#isElement"><b>isElement</b></a> () const</div></li><li><div class=fn>QString <a href="#text"><b>text</b></a> () const</div></li></ul><hr><a name="details"></a><h2>Detailed Description</h2>The QDomElement class represents one element in the DOM tree.<p> <p> Elements have a <a href="#tagName">tagName</a>() and zero or more attributes associated with them.The tag name can be changed with <a href="#setTagName">setTagName</a>().<p> Attributes of the element are represented by <a href="qdomattr.html">QDomAttr</a> objects, that can bequeried using the <a href="#attribute">attribute</a>() and <a href="#attributeNode">attributeNode</a>() functions. You can setattributes with the <a href="#setAttribute">setAttribute</a>() and <a href="#setAttributeNode">setAttributeNode</a>() functions.Attributes can be removed with <a href="#removeAttribute">removeAttribute</a>(). There are namespace-awareequivalents to these functions, i.e. <a href="#setAttributeNS">setAttributeNS</a>(), <a href="#setAttributeNodeNS">setAttributeNodeNS</a>()and <a href="#removeAttributeNS">removeAttributeNS</a>().<p> If you want to access the text of a node use <a href="#text">text</a>(), e.g.<pre>    QDomElement e = //...    //...    <a href="qstring.html">QString</a> s = e.<a href="#text">text</a>()    </pre> The text() function operates recursively to find the text (since notall elements contain text). If you want to find all the text in allof a node's children iterate over the children looking for <a href="qdomtext.html">QDomText</a>nodes, e.g.<pre>    <a href="qstring.html">QString</a> text;    QDomElement element = doc.documentElement();    for( <a href="qdomnode.html">QDomNode</a> n = element.<a href="qdomnode.html#firstChild">firstChild</a>(); !n.<a href="qdomnode.html#isNull">isNull</a>(); n = n.<a href="qdomnode.html#nextSibling">nextSibling</a>() )    {             <a href="qdomtext.html">QDomText</a> t = n.<a href="qdomnode.html#toText">toText</a>();             if ( !t.<a href="qdomnode.html#isNull">isNull</a>() )                     text += t.<a href="qdomcharacterdata.html#data">data</a>();    }    </pre> Note that we attempt to convert each node to a text node and use<a href="#text">text</a>() rather than using <a href="qdomnode.html#firstChild">firstChild</a>().<a href="qdomnode.html#toText">toText</a>().data() orn.toText().data() directly on the node, because the node may not bea text element.<p> You can get a list of all the decendents of an element which have aspecified tag name with <a href="#elementsByTagName">elementsByTagName</a>() or  <a href="#elementsByTagNameNS">elementsByTagNameNS</a>().<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<a href="qdomdocument.html">QDomDocument</a> documentation.<p>See also <a href="xml-tools.html">XML</a>.<hr><h2>Member Function Documentation</h2><h3 class=fn><a name="QDomElement"></a>QDomElement::QDomElement ()</h3>Constructs an empty element. Use the <a href="qdomdocument.html#createElement">QDomDocument::createElement</a>() functionto construct elements with content.<h3 class=fn><a name="QDomElement-2"></a>QDomElement::QDomElement ( const&nbsp;<a href="qdomelement.html">QDomElement</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 alsochange 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="~QDomElement"></a>QDomElement::~QDomElement ()</h3>Destroys the object and frees its resources.<h3 class=fn><a href="qstring.html">QString</a> <a name="attribute"></a>QDomElement::attribute ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;name, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;defValue = QString::null ) const</h3>Returns the attribute called <em>name</em>. If the attribute does not exist<em>defValue</em> is returned.<p> <p>See also <a href="#setAttribute">setAttribute</a>(), <a href="#attributeNode">attributeNode</a>(), <a href="#setAttributeNode">setAttributeNode</a>() and <a href="#attributeNS">attributeNS</a>().<h3 class=fn><a href="qstring.html">QString</a> <a name="attributeNS"></a>QDomElement::attributeNS ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;nsURI, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;localName, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;defValue ) const</h3>Returns the attribute with the local name <em>localName</em> and the namespace URI<em>nsURI</em>. If the attribute does not exist <em>defValue</em> is returned.<p> <p>See also <a href="#setAttributeNS">setAttributeNS</a>(), <a href="#attributeNodeNS">attributeNodeNS</a>(), <a href="#setAttributeNodeNS">setAttributeNodeNS</a>() and <a href="#attribute">attribute</a>().<h3 class=fn><a href="qdomattr.html">QDomAttr</a> <a name="attributeNode"></a>QDomElement::attributeNode ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;name )</h3>Returns the <a href="qdomattr.html">QDomAttr</a> object that corresponds to the attribute called<em>name</em>.  If no such attribute exists a null object is returned.<p> <p>See also <a href="#setAttributeNode">setAttributeNode</a>(), <a href="#attribute">attribute</a>(), <a href="#setAttribute">setAttribute</a>() and <a href="#attributeNodeNS">attributeNodeNS</a>().<h3 class=fn><a href="qdomattr.html">QDomAttr</a> <a name="attributeNodeNS"></a>QDomElement::attributeNodeNS ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;nsURI, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;localName )</h3>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?