public override bool MoveToFollowing(string localName, string namespaceUri, XPathNavigator end) {
XmlNode pastFollowing = null;
DocumentXPathNavigator that = end as DocumentXPathNavigator;
if (that != null) {
if (document != that.document) {
return false;
}
switch (that.source.NodeType) {
case XmlNodeType.Attribute:
that = (DocumentXPathNavigator)that.Clone();
if (!that.MoveToNonDescendant()) {
return false;
}
break;
}
pastFollowing = that.source;
}
XmlNode following = source;
if (following.NodeType == XmlNodeType.Attribute) {
following = ((XmlAttribute)following).OwnerElement;
if (following == null) {
return false;
}
}
do {
XmlNode firstChild = following.FirstChild;
if (firstChild != null) {
following = firstChild;
}
else {
for (;;) {
XmlNode nextSibling = following.NextSibling;
if (nextSibling != null) {
following = nextSibling;
break;
}
else {
XmlNode parent = following.ParentNode;
if (parent != null) {
following = parent;
}
else {
return false;
}
}
}
}
if (following == pastFollowing) {
return false;
}
}
while (following.NodeType != XmlNodeType.Element
|| following.LocalName != localName
|| following.NamespaceURI != namespaceUri);
source = following;
return true;
}