Share via


GetDepth

 

Returns the depth of the current node in the document.

Syntax

  
HRESULT GetDepth([out, retval] UINT * pnDepth);  

Arguments

pnDepth
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 greater than the depth of the element that contains it.

This method is intended to be used primarily to defend against denial of service attacks in which a malicious XML document could cause a malfunction in the parser due to 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.

Requirements

Header: XmlLite.h

Library: XmlLite.lib

See Also

IXmlReader Methods