Share via


GetAttributeCount (Compact 2013)

3/26/2014

This interface returns the number of attributes in the current node.

Syntax

HRESULT GetAttributeCount(
    UINT* pnAttributeCount
);

Arguments

  • pnAttributeCount
    [out, retval] 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>

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

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

This method lets 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 to provide performance benefits.

See Also

Reference

IXmlReader Methods
IXmlReader Properties
Error Codes