XmlNode.SelectSingleNode syntax to search within a node in C#

前端 未结 2 701
醉梦人生
醉梦人生 2021-01-02 01:16

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         


        
2条回答
  •  臣服心动
    2021-01-02 01:38

    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")
    

提交回复
热议问题