public virtual bool ReadToDescendant(string localName, string namespaceURI)
{
if (localName == null || localName.Length == 0)
{
throw XmlConvert.CreateInvalidNameArgumentException(localName, nameof(localName));
}
if (namespaceURI == null)
{
throw new ArgumentNullException(nameof(namespaceURI));
}
// save the element or root depth
int parentDepth = Depth;
if (NodeType != XmlNodeType.Element)
{
// adjust the depth if we are on root node
if (ReadState == ReadState.Initial)
{
Debug.Assert(parentDepth == 0);
parentDepth--;
}
else
{
return false;
}
}
else if (IsEmptyElement)
{
return false;
}
// atomize local name and namespace
localName = NameTable.Add(localName);
namespaceURI = NameTable.Add(namespaceURI);
// find the descendant
while (Read() && Depth > parentDepth)
{
if (NodeType == XmlNodeType.Element && Ref.Equal(localName, LocalName) && Ref.Equal(namespaceURI, NamespaceURI))
{
return true;
}
}
Debug.Assert(NodeType == XmlNodeType.EndElement);
return false;
}