QDomNamedNodeMap Class Reference

[ QtXml module]

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

方法

Special Methods


详细描述

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:

  1. QDomDocumentType.entities () returns a map of all entities described in the DTD.
  2. QDomDocumentType.notations () returns a map of all notations described in the DTD.
  3. QDomNode.attributes () returns a map of all attributes of an element.

Items in the map are identified by the name which QDomNode.name() returns. Nodes are retrieved using namedItem (), namedItemNS () 或 item (). New nodes are inserted with setNamedItem () 或 setNamedItemNS () 和 removed with removeNamedItem () 或 removeNamedItemNS (). 使用 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.


方法文档编制

QDomNamedNodeMap.__init__ ( self )

Constructs an empty named node map.

QDomNamedNodeMap.__init__ ( self , QDomNamedNodeMap )

构造副本为 n .

bool QDomNamedNodeMap.contains ( self , QString  name )

Returns true if the map contains a node called name ; otherwise returns false.

注意: This function does not take the presence of namespaces into account. Use namedItemNS () to test whether the map contains a node with a specific namespace URI and name.

int QDomNamedNodeMap.count ( self )

This function is provided for Qt API consistency. It is equivalent to length ().

bool QDomNamedNodeMap.isEmpty ( self )

Returns true if the map is empty; otherwise returns false. This function is provided for Qt API consistency.

QDomNode QDomNamedNodeMap.item ( self , int  index )

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.

另请参阅 length ().

int QDomNamedNodeMap.length ( self )

Returns the number of nodes in the map.

另请参阅 item ().

QDomNode QDomNamedNodeMap.namedItem ( self , QString  name )

Returns the node called name .

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

另请参阅 setNamedItem () 和 namedItemNS ().

QDomNode QDomNamedNodeMap.namedItemNS ( self , QString  nsURI , QString  localName )

Returns the node associated with the local name localName 和名称空间 URI nsURI .

If the map does not contain such a node, a null 节点 被返回。

另请参阅 setNamedItemNS () 和 namedItem ().

QDomNode QDomNamedNodeMap.removeNamedItem ( self , QString  name )

Removes the node called name from the map.

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

另请参阅 setNamedItem (), namedItem (),和 removeNamedItemNS ().

QDomNode QDomNamedNodeMap.removeNamedItemNS ( self , QString  nsURI , QString  localName )

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

The function returns the removed node or a null 节点 if the map did not contain a node with the local name localName 和名称空间 URI nsURI .

另请参阅 setNamedItemNS (), namedItemNS (),和 removeNamedItem ().

QDomNode QDomNamedNodeMap.setNamedItem ( self , QDomNode   newNode )

插入节点 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.

另请参阅 namedItem (), removeNamedItem (),和 setNamedItemNS ().

QDomNode QDomNamedNodeMap.setNamedItemNS ( self , QDomNode   newNode )

插入节点 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.

另请参阅 namedItemNS (), removeNamedItemNS (), and setNamedItem ().

int QDomNamedNodeMap.size ( self )

This function is provided for Qt API consistency. It is equivalent to length ().

bool QDomNamedNodeMap.__eq__ ( self , QDomNamedNodeMap )

QDomNamedNodeMap.__len__ ( self )

bool QDomNamedNodeMap.__ne__ ( self , QDomNamedNodeMap )