XPath and Selecting a single node

后端 未结 4 1457
北荒
北荒 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:40

    The // you use in front of stuffChild means you're looking for stuffChild elements, starting from the root.

    If you want to start from the current node (decendants of the current node), you should use .//, as in:

    stuff.SelectSingleNode(".//stuffChild");
    

提交回复
热议问题