다음을 통해 공유


GetAttributeCount

 

Returns the number of attributes in the current node.

Syntax

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

Arguments

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

Return Value

Returns S_OK if no error is generated.

Remarks

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.

Requirements

Header: XmlLite.h

Library: XmlLite.lib

See Also

IXmlReader Methods