返回介绍

QDomNamedNodeMap Class

发布于 2019-10-04 14:59:48 字数 6393 浏览 1247 评论 0 收藏 0

The QDomNamedNodeMap class contains a collection of nodes that can be accessed by name. More...

#include <qdom.h>

List of all member functions.

Public Members

  • QDomNamedNodeMap ()
  • QDomNamedNodeMap ( constQDomNamedNodeMap&n )
  • QDomNamedNodeMap & operator= ( constQDomNamedNodeMap&n )
  • bool operator== ( constQDomNamedNodeMap&n ) const
  • bool operator!= ( constQDomNamedNodeMap&n ) const
  • ~QDomNamedNodeMap ()
  • QDomNode namedItem ( constQString&name ) const
  • QDomNode setNamedItem ( constQDomNode&newNode )
  • QDomNode removeNamedItem ( constQString&name )
  • QDomNode item ( intindex ) const
  • QDomNode namedItemNS ( constQString&nsURI, constQString&localName ) const
  • QDomNode setNamedItemNS ( constQDomNode&newNode )
  • QDomNode removeNamedItemNS ( constQString&nsURI, constQString&localName )
  • uint length () const
  • uint count () const
  • bool contains ( constQString&name ) const

Detailed Description

The QDomNamedNodeMap class contains a collection of nodes that can be accessed by name.

Note that QDomNamedNodeMap does not inherit from QDomNodeList. QDomNamedNodeMaps do not provide any specific node ordering. Although nodes in a QDomNamedNodeMap may be accessed by an ordinal index, this is simply to allow a convenient enumeration of the contents of a QDomNamedNodeMap, and does not imply that the DOM specifies an ordering of the nodes.

The QDomNamedNodeMap is used in three places:

  • QDomDocumentType::entities() returns a map of all entities described in the DTD.
  • QDomDocumentType::notations() returns a map of all notations described in the DTD.
  • QDomNode::attributes() returns a map of all attributes of the element.

Items in the map are identified by the name which QDomNode::name() returns. Nodes are retrieved using namedItem(), namedItemNS() or item(). New nodes are inserted with setNamedItem() or setNamedItem() and removed with removeNamedItem() or removeNamedItemNS(). Use contains() to see if an item with the given name is in the named node map. The number of items is returned by length().

Terminology: in this class we use "item" and "node" interchangeably.

See also XML.


Member Function Documentation

QDomNamedNodeMap::QDomNamedNodeMap ()

Constructs an empty named node map.

QDomNamedNodeMap::QDomNamedNodeMap ( constQDomNamedNodeMap&n )

Constructs a copy of n.

QDomNamedNodeMap::~QDomNamedNodeMap ()

Destroys the object and frees its resources.

bool QDomNamedNodeMap::contains ( constQString&name ) const

Returns TRUE if the map contains a node called name; otherwise returns FALSE.

uint QDomNamedNodeMap::count () const

Returns the number of nodes in the map.

This function is the same as length().

QDomNode QDomNamedNodeMap::item ( intindex ) const

Retrieves the node at position index.

This can be used to iterate over the map. Note that the nodes in the map are ordered arbitrarily.

See also length().

uint QDomNamedNodeMap::length () const

Returns the number of nodes in the map.

See also item().

QDomNode QDomNamedNodeMap::namedItem ( constQString&name ) const

Returns the node called name.

If the named node map does not contain such a node, a null node is returned. A node's name is the name returned by QDomNode::nodeName().

See also setNamedItem() and namedItemNS().

QDomNode QDomNamedNodeMap::namedItemNS ( constQString&nsURI, constQString&localName ) const

Returns the node associated with the local name localName and the namespace URI nsURI.

If the map does not contain such a node, a null node is returned.

See also setNamedItemNS() and namedItem().

bool QDomNamedNodeMap::operator!= ( constQDomNamedNodeMap&n ) const

Returns TRUE if n and this named node map are not equal; otherwise returns FALSE.

QDomNamedNodeMap& QDomNamedNodeMap::operator= ( constQDomNamedNodeMap&n )

Assigns n to this named node map.

bool QDomNamedNodeMap::operator== ( constQDomNamedNodeMap&n ) const

Returns TRUE if n and this named node map are equal; otherwise returns FALSE.

QDomNode QDomNamedNodeMap::removeNamedItem ( constQString&name )

Removes the node called name from the map.

The function returns the removed node or a null node if the map did not contain a node called name.

See also setNamedItem(), namedItem() and removeNamedItemNS().

QDomNode QDomNamedNodeMap::removeNamedItemNS ( constQString&nsURI, constQString&localName )

Removes the node with the local name localName and the namespace URI nsURI from the map.

The function returns the removed node or a null node if the map did not contain a node with the local name localName and the namespace URI nsURI.

See also setNamedItemNS(), namedItemNS() and removeNamedItem().

QDomNode QDomNamedNodeMap::setNamedItem ( constQDomNode&newNode )

Inserts the node newNode into the named node map. The name used by the map is the node name of newNode as returned by QDomNode::nodeName().

If the new node replaces an existing node, i.e. the map contains a node with the same name, the replaced node is returned.

See also namedItem(), removeNamedItem() and setNamedItemNS().

QDomNode QDomNamedNodeMap::setNamedItemNS ( constQDomNode&newNode )

Inserts the node newNode in the map. If a node with the same namespace URI and the same local name already exists in the map, it is replaced by newNode. If the new node replaces an existing node, the replaced node is returned.

See also namedItemNS(), removeNamedItemNS() and setNamedItem().

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文