XPath and Selecting a single node

后端 未结 4 1401
北荒
北荒 2021-02-08 06:57

I\'m using XPath in .NET to parse an XML document, along the lines of:

XmlNodeList lotsOStuff = doc.SelectNodes(\"//stuff\         


        
4条回答
  •  星月不相逢
    2021-02-08 07:56

    Selecting single node means you need only the first element. So, the best solution is:

    XmlNode stuffChild = stuff.SelectSingleNode("descendant::stuffChild[1]");
    

提交回复
热议问题