GetDepth

 

Returns the depth of the current node in the document.

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

pnDepth
The depth of the current node. The passed in value cannot be NULL.

Returns S_OK if no error is generated.

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.

Header: XmlLite.h

Library: XmlLite.lib

IXmlReader Methods

Show: