Share via


GetDepth (Compact 2013)

3/26/2014

This interface returns the depth of the current node.

Syntax

HRESULT GetDepth(
    UINT* pnDepth
);

Arguments

  • pnDepth
    [out, retval] The depth of the current node. The passed-in value cannot be NULL.

Return Value

Returns S_OK if no error is generated.

Remarks

The depth is the level of nesting of the current node. The depth of an attribute is one larger than the depth of the element that contains it.

This method is intended to be primarily used to defend against denial of service attacks in which a malicious XML document can cause a malfunction in the parser caused by excessively nested nodes.

Retrieving the depth while positioned on an XmlNodeType_Element or XmlNodeType_EndElement node returns the depth before processing the node. For example, consider the following document:

<Parent>
<Child>
</Child>
</Parent>

When positioned on the <Parent> start node, the depth is reported as 0.

When positioned on the <Child> start node, the depth is reported as 1.

When positioned on the </Child> end node, the depth is reported as 2.

When positioned on the </Parent> end node, the depth is reported as 1.

See Also

Reference

IXmlReader Methods
IXmlReader Properties
Error Codes