XML Methods Ending in “2” (GetRoot2, GetChild2, GetParent2, NextSibling2, …)
A Chilkat XML object represents a single node within an XML document. The “root” is the topmost node in the XML document tree. As long as at least a single reference to a node (anywhere in the tree) exists, the entire XML tree remains in memory.
Typically, an XML API returns a new node object when navigating. Chilkat XML does this also. For example:
// Get the 1st child: Chilkat.Xml childNode = xmlDoc.GetChild(0);
For efficiency, Chilkat provides alternate methods such that instead of returning a new object, the internal pointer of the Chilkat XML object is updated. This can vastly reduce the proliferation of objects that might need to be allocated/deallocated or garbage collected. For example:
xmlDoc.GetChild2(0); // xmlDoc now references the 1st child. xmlDoc.GetParent2(); // xmlDoc is now back to where it began. // Regardless of the location of an XML object in the tree, // you may always return to the document root like this: xml.GetRoot2();