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

前端 未结 2 684
醉梦人生
醉梦人生 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:39

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

提交回复
热议问题