I want to limit my search for a child node to be within the current node I am on. For example, I have the following code:
XmlNodeList myNodes = xmlDoc.Docum
Actually, the problem relates to XPath. XPath syntax // means you select nodes in the document from the current node that match the selection no matter where they are
so all you need is to change it to
myNode.SelectSingleNode(".LastName")
A leading //
always starts at the root of the document; use .//
to start at the current node and search just its descendants:
XmlNode lastnameNode = myNode.SelectSingleNode(".//LastName");