ResetMainPos method clears the current main position and child position, without affecting the current parent position. This is different from ResetPos which completely clears the current position.
ResetMainPos is used to restart a loop through sibling elements under the same parent position within the document. It also allows you to insert an element as the first child of the parent position element when you call InsertElem.
In this sample document, the ROOT element has three child elements X, Y and Z.
<ROOT> <X/> <Y/> <Z/> </ROOT>
This code demonstrates that if Z is your current main position you must use
ResetMainPos so that FindElem can locate the X element.
xml.ResetPos(); xml.FindElem(); // ROOT xml.IntoElem(); // Before X xml.FindElem( "Z" ); // At Z xml.FindElem( "X" ); // Fails, still at Z xml.ResetMainPos(); xml.FindElem( "X" ); // At X
Navigating and Getting Information From a Document
Navigating Levels in CMarkup