<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                # QDomElement Class Reference ## [[QtXml](index.htm) module] 該QDomElement類表示的DOM樹中的元素。[More...](#details) 繼承[QDomNode](qdomnode.html)。 ### Methods * `__init__ (self)` * `__init__ (self, QDomElement?x)` * `QString attribute (self, QString?name, QString?defaultValue?=?QString())` * `QDomAttr attributeNode (self, QString?name)` * `QDomAttr attributeNodeNS (self, QString?nsURI, QString?localName)` * `QString attributeNS (self, QString?nsURI, QString?localName, QString?defaultValue?=?QString())` * `QDomNamedNodeMap attributes (self)` * `QDomNodeList elementsByTagName (self, QString?tagname)` * `QDomNodeList elementsByTagNameNS (self, QString?nsURI, QString?localName)` * `bool hasAttribute (self, QString?name)` * `bool hasAttributeNS (self, QString?nsURI, QString?localName)` * `QDomNode.NodeType nodeType (self)` * `removeAttribute (self, QString?name)` * `QDomAttr removeAttributeNode (self, QDomAttr?oldAttr)` * `removeAttributeNS (self, QString?nsURI, QString?localName)` * `setAttribute (self, QString?name, QString?value)` * `setAttribute (self, QString?name, int?value)` * `setAttribute (self, QString?name, int?value)` * `setAttribute (self, QString?name, float?value)` * `setAttribute (self, QString?name, int?value)` * `QDomAttr setAttributeNode (self, QDomAttr?newAttr)` * `QDomAttr setAttributeNodeNS (self, QDomAttr?newAttr)` * `setAttributeNS (self, QString?nsURI, QString?qName, QString?value)` * `setAttributeNS (self, QString?nsURI, QString?qName, int?value)` * `setAttributeNS (self, QString?nsURI, QString?qName, int?value)` * `setAttributeNS (self, QString?nsURI, QString?qName, float?value)` * `setAttributeNS (self, QString?nsURI, QString?qName, int?value)` * `setTagName (self, QString?name)` * `QString tagName (self)` * `QString text (self)` * * * ## Detailed Description 該QDomElement類表示的DOM樹中的元素。 元素有一個[tagName](qdomelement.html#tagName)()和與它們相關聯的零個或多個屬性。變量名可以被改變[setTagName](qdomelement.html#setTagName)( ) 。 元素屬性表示為[QDomAttr](qdomattr.html)可以使用查詢對象的[attribute](qdomelement.html#attributex)()和[attributeNode](qdomelement.html#attributeNode)()函數。您可以設置的屬性與[setAttribute](qdomelement.html#setAttribute)()和[setAttributeNode](qdomelement.html#setAttributeNode)()函數。屬性可以用去除[removeAttribute](qdomelement.html#removeAttribute)( ) 。有命名空間的等值這些功能,即[setAttributeNS](qdomelement.html#setAttributeNS)( )[setAttributeNodeNS](qdomelement.html#setAttributeNodeNS)()和[removeAttributeNS](qdomelement.html#removeAttributeNS)( ) 。 如果您要訪問的節點使用的文字[text](qdomelement.html#text)( ),例如 ``` QDomElement e = //... //... [QString](qstring.html) s = e.text() ``` 該[text](qdomelement.html#text)( )函數的遞歸操作要查找的文本(因為不是所有的元素包含文本)。如果你想找到的所有的節點的子節點的所有文字,迭代孩子找[QDomText](qdomtext.html)節點,例如 ``` [QString](qstring.html) text; QDomElement element = doc.documentElement(); for([QDomNode](qdomnode.html) n = element.firstChild(); !n.isNull(); n = n.nextSibling()) { [QDomText](qdomtext.html) t = n.toText(); if (!t.isNull()) text += t.data(); } ``` 需要注意的是,我們試圖給每個節點轉換為文本節點,并使用[text](qdomelement.html#text)() ,而不是使用[firstChild](qdomnode.html#firstChild)( ) 。[toText](qdomnode.html#toText)( )數據( )或n 。[toText](qdomnode.html#toText)() 。數據()直接在節點上,因為節點可能不是一個文本元素。 你可以得到一個元素的所有那些與一個指定的標記名稱的decendents列表[elementsByTagName](qdomelement.html#elementsByTagName)()或[elementsByTagNameNS](qdomelement.html#elementsByTagNameNS)( ) 。 要瀏覽一個DOM文檔使用的元素[firstChildElement](qdomnode.html#firstChildElement)( )[lastChildElement](qdomnode.html#lastChildElement)( )[nextSiblingElement](qdomnode.html#nextSiblingElement)()和[previousSiblingElement](qdomnode.html#previousSiblingElement)( ) 。例如,迭代中被稱為“數據庫”根元素稱為“入口”的所有子元素,你可以使用: ``` [QDomDocument](qdomdocument.html) doc = // ... QDomElement root = doc.firstChildElement("database"); QDomElement elt = root.firstChildElement("entry"); for (; !elt.isNull(); elt = elt.nextSiblingElement("entry")) { // ... } ``` 關于文檔對象模型有進一步的信息[Level 1](http://www.w3.org/TR/REC-DOM-Level-1/)和[Level 2 Core](http://www.w3.org/TR/DOM-Level-2-Core/)。對于更一般介紹的DOM實現的見[QDomDocument](qdomdocument.html)文檔。 * * * ## Method Documentation ``` QDomElement.__init__ (self) ``` 構造一個空元素。使用[QDomDocument.createElement](qdomdocument.html#createElement)( )函數來構造與內容元素。 ``` QDomElement.__init__ (self, QDomElement?x) ``` 構造的副本_x_。 副本的數據是共享的(淺拷貝) :修改一個節點也將改變其他。如果你想使一個深拷貝,使用[cloneNode](qdomnode.html#cloneNode)( ) 。 ``` QString QDomElement.attribute (self, QString?name, QString?defaultValue?=?QString()) ``` ``` QDomAttr QDomElement.attributeNode (self, QString?name) ``` [](qdomattr.html) [返回](qdomattr.html)[QDomAttr](qdomattr.html)對應于所謂的屬性對象_name_。如果沒有這樣的屬性存在一[null attribute](qdomnode.html#isNull)返回。 **See also** [setAttributeNode](qdomelement.html#setAttributeNode)( )[attribute](qdomelement.html#attributex)( )[setAttribute](qdomelement.html#setAttribute)()和[attributeNodeNS](qdomelement.html#attributeNodeNS)( ) 。 ``` QDomAttr QDomElement.attributeNodeNS (self, QString?nsURI, QString?localName) ``` [](qdomattr.html) [返回](qdomattr.html)[QDomAttr](qdomattr.html)對應于屬性的本地名稱對象_localName_和命名空間URI_nsURI_。如果沒有這樣的屬性存在一[null attribute](qdomnode.html#isNull)返回。 **See also** [setAttributeNodeNS](qdomelement.html#setAttributeNodeNS)( )[setAttributeNode](qdomelement.html#setAttributeNode)( )[attribute](qdomelement.html#attributex)()和[setAttribute](qdomelement.html#setAttribute)( ) 。 ``` QString QDomElement.attributeNS (self, QString?nsURI, QString?localName, QString?defaultValue?=?QString()) ``` 返回與本地名屬性_localName_和命名空間URI_nsURI_。如果屬性不存在_defValue_返回。 **See also** [setAttributeNS](qdomelement.html#setAttributeNS)( )[attributeNodeNS](qdomelement.html#attributeNodeNS)( )[setAttributeNodeNS](qdomelement.html#setAttributeNodeNS)()和[attribute](qdomelement.html#attributex)( ) 。 ``` QDomNamedNodeMap QDomElement.attributes (self) ``` [](qdomnamednodemap.html) [返回](qdomnamednodemap.html)[QDomNamedNodeMap](qdomnamednodemap.html)包含此元素的所有屬性。 **See also** [attribute](qdomelement.html#attributex)( )[setAttribute](qdomelement.html#setAttribute)( )[attributeNode](qdomelement.html#attributeNode)()和[setAttributeNode](qdomelement.html#setAttributeNode)( ) 。 ``` QDomNodeList QDomElement.elementsByTagName (self, QString?tagname) ``` [](qdomnodelist.html) [返回](qdomnodelist.html)[QDomNodeList](qdomnodelist.html)含命名該元素的所有后代_tagname_在子樹中的元素與此元素為根的前序遍歷遇到。在返回列表中的元素的順序是它們的前序遍歷過程中出現的順序。 **See also** [elementsByTagNameNS](qdomelement.html#elementsByTagNameNS)()和[QDomDocument.elementsByTagName](qdomdocument.html#elementsByTagName)( ) 。 ``` QDomNodeList QDomElement.elementsByTagNameNS (self, QString?nsURI, QString?localName) ``` [](qdomnodelist.html) [返回](qdomnodelist.html)[QDomNodeList](qdomnodelist.html)包含此元素的所有后代與當地名_localName_和命名空間URI_nsURI_在子樹中的元素與此元素為根的前序遍歷遇到。在返回列表中的元素的順序是它們的前序遍歷過程中出現的順序。 **See also** [elementsByTagName](qdomelement.html#elementsByTagName)()和[QDomDocument.elementsByTagNameNS](qdomdocument.html#elementsByTagNameNS)( ) 。 ``` bool QDomElement.hasAttribute (self, QString?name) ``` 如果此元素有一個名為屬性,則返回True_name_否則返回False 。 **Note:**這個功能并不需要命名空間的存在考慮。因此,指定的名稱將針對完全合格的屬性名,包括任何命名空間前綴可能存在的測試。 使用[hasAttributeNS](qdomelement.html#hasAttributeNS)()來為特定的命名空間和名稱的屬性明確地測試。 ``` bool QDomElement.hasAttributeNS (self, QString?nsURI, QString?localName) ``` 如果此元素具有與當地名稱的屬性,則返回True_localName_和命名空間URI_nsURI_否則返回False 。 ``` QDomNode.NodeType QDomElement.nodeType (self) ``` [ Returns `ElementNode`。 ``` QDomElement.removeAttribute (self, QString?name) ``` 消除了所謂的屬性名稱_name_從這個項目。 ](qdomnode.html#NodeType-enum) [**See also**](qdomnode.html#NodeType-enum) [setAttribute](qdomelement.html#setAttribute)( )[attribute](qdomelement.html#attributex)()和[removeAttributeNS](qdomelement.html#removeAttributeNS)( ) 。 ``` QDomAttr QDomElement.removeAttributeNode (self, QDomAttr?oldAttr) ``` [ 移除屬性_oldAttr_從元素并返回它。 ](qdomattr.html) [**See also**](qdomattr.html) [attributeNode](qdomelement.html#attributeNode)()和[setAttributeNode](qdomelement.html#setAttributeNode)( ) 。 ``` QDomElement.removeAttributeNS (self, QString?nsURI, QString?localName) ``` 刪除該屬性的本地名稱_localName_和命名空間URI_nsURI_從這個項目。 **See also** [setAttributeNS](qdomelement.html#setAttributeNS)( )[attributeNS](qdomelement.html#attributeNS)()和[removeAttribute](qdomelement.html#removeAttribute)( ) 。 ``` QDomElement.setAttribute (self, QString?name, QString?value) ``` 添加稱為屬性_name_與價值_value_。如果具有相同名稱的屬性存在,它的值被替換_value_。 **See also** [attribute](qdomelement.html#attributex)( )[setAttributeNode](qdomelement.html#setAttributeNode)()和[setAttributeNS](qdomelement.html#setAttributeNS)( ) 。 ``` QDomElement.setAttribute (self, QString?name, int?value) ``` 這是一個重載函數。 數是根據當前的區域設置。 ``` QDomElement.setAttribute (self, QString?name, int?value) ``` 這是一個重載函數。 數是根據當前的區域設置。 ``` QDomElement.setAttribute (self, QString?name, float?value) ``` 這是一個重載函數。 數是根據當前的區域設置。 ``` QDomElement.setAttribute (self, QString?name, int?value) ``` 這是一個重載函數。 數是根據當前的區域設置。 ``` QDomAttr QDomElement.setAttributeNode (self, QDomAttr?newAttr) ``` [ 添加屬性_newAttr_此元素。 ](qdomattr.html) [如果該元件具有一個具有相同名稱的另一個屬性_newAttr_,這個函數替換該屬性并返回它,否則該函數返回一個](qdomattr.html)[null attribute](qdomnode.html#isNull)。 **See also** [attributeNode](qdomelement.html#attributeNode)( )[setAttribute](qdomelement.html#setAttribute)()和[setAttributeNodeNS](qdomelement.html#setAttributeNodeNS)( ) 。 ``` QDomAttr QDomElement.setAttributeNodeNS (self, QDomAttr?newAttr) ``` [ 添加屬性_newAttr_此元素。 ](qdomattr.html) [如果元素具有具有相同的本地名稱和命名空間URI作為另一個屬性_newAttr_,這個函數替換該屬性并返回它,否則該函數返回一個](qdomattr.html)[null attribute](qdomnode.html#isNull)。 **See also** [attributeNodeNS](qdomelement.html#attributeNodeNS)( )[setAttributeNS](qdomelement.html#setAttributeNS)()和[setAttributeNode](qdomelement.html#setAttributeNode)( ) 。 ``` QDomElement.setAttributeNS (self, QString?nsURI, QString?qName, QString?value) ``` 添加具有限定名稱的屬性_qName_和命名空間URI_nsURI_與該值_value_。如果具有相同的本地名稱和名稱空間URI存在的屬性,它的前綴被替換的前綴_qName_其值由repaced_value_。 雖然_qName_是合格的名稱,本地名稱是用來決定是否將現有屬性的值應及時更換。 **See also** [attributeNS](qdomelement.html#attributeNS)( )[setAttributeNodeNS](qdomelement.html#setAttributeNodeNS)()和[setAttribute](qdomelement.html#setAttribute)( ) 。 ``` QDomElement.setAttributeNS (self, QString?nsURI, QString?qName, int?value) ``` 這是一個重載函數。 ``` QDomElement.setAttributeNS (self, QString?nsURI, QString?qName, int?value) ``` 這是一個重載函數。 ``` QDomElement.setAttributeNS (self, QString?nsURI, QString?qName, float?value) ``` 這是一個重載函數。 ``` QDomElement.setAttributeNS (self, QString?nsURI, QString?qName, int?value) ``` 這是一個重載函數。 ``` QDomElement.setTagName (self, QString?name) ``` 設置此元素的標籤名_name_。 **See also** [tagName](qdomelement.html#tagName)( ) 。 ``` QString QDomElement.tagName (self) ``` 返回此元素的標籤名稱。對于這樣的一個XML元素: ``` <img src="myimg.png"> ``` 標記名會返回“ IMG ” 。 **See also** [setTagName](qdomelement.html#setTagName)( ) 。 ``` QString QDomElement.text (self) ``` 返回元素的文本或空字符串。 例如: ``` <h1>Hello <b>[Qt](qt.html)</b> <![CDATA[<xml is cool>]]></h1> ``` 的功能文本( )[QDomElement](qdomelement.html)為`&lt;h1&gt;`標籤,將返回以下文本: ``` Hello [Qt](qt.html) <xml is cool> ``` 注釋此函數忽略。只計算[QDomText](qdomtext.html)和[QDomCDATASection](qdomcdatasection.html)對象。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看