GetAttributeCount

 

Returns the number of attributes in the current node.

  
HRESULT GetAttributeCount([out, retval] UINT * pnAttributeCount);  

pnAttributeCount
The number of attributes for the current node. The passed in value cannot be NULL.

Returns S_OK if no error is generated.

For Element, XmlDeclaration, and DocumentType nodes, this method returns the number of attributes for the node.

For Attribute nodes, the method returns the number of attributes for the Element node that owns the current attribute.

For any other nodes the method returns 0.

Consider the following example:

<?xml version="1.0" encoding="utf-8" ?>  
<book name=”My Funny Book” publisher="Funny Book Press" address="123 Infinite Loop">  
    ...  
</book>  

While on the xml declaration, version, or encoding, the attribute count will be 2.

While on book, name, publisher, or address the attribute count will be 3.

This method allows the application writer to inspect the number of attributes on the node. This enables the allocation of an appropriate amount of memory for storing the attributes if necessary. This can provide performance benefits.

Header: XmlLite.h

Library: XmlLite.lib

IXmlReader Methods

Show: