private bool ReadForward( bool fSkipChildren ) {
if ( readState == ReadState.Error )
return false;
if ( !bStartFromDocument && curDepth == 0 ) {
//already on top most node and we shouldn't move to next
return ReadAtZeroLevel(fSkipChildren);
}
//else either we are not on top level or we are starting from the document at the very beginning in which case
// we will need to read all the "top" most nodes
if ( readerNav.MoveToNext() ) {
nodeType = readerNav.NodeType;
return true;
} else {
//need to check its parent
if ( curDepth == 0 )
return ReadAtZeroLevel(fSkipChildren);
if ( readerNav.MoveToParent() ) {
if ( readerNav.NodeType == XmlNodeType.Element ) {
curDepth--;
nodeType = XmlNodeType.EndElement;
return true;
} else if ( readerNav.NodeType == XmlNodeType.EntityReference ) {
//coming back from entity reference node -- must be getting down through call ResolveEntity()
curDepth--;
nodeType = XmlNodeType.EndEntity;
return true;
}
return true;
}
}
return false;
}