Double slash // means any descendant node of the current node in the html tree which matches the locator.

Single slash / means node which is a direct child of the current.

//div[@id='add']//span[@id=addone'] will match

<div id="add">
  <div>
    <span id="addone">
  </div>
</div>

And

<div id="add">
    <span id="addone">
</div>

//div[@id='add']/span[@id=addone'] will match only the second html tree.

 

 

https://stackoverflow.com/questions/1457638/xpath-get-nodes-where-child-node-contains-an-attribute

/// <summary>
/// 
/// </summary>
[Test]
public void Test()
{
XmlDocument document = new XmlDocument();
document.Load(@"C:\Users\clu\Desktop\test.xml");
XPathNavigator navigator = document.CreateNavigator();
var nodeList = navigator.Select(@"//book[title/@lang = 'it']");
Console.WriteLine(nodeList.Count);
}

 

相关文章:

  • 2021-12-05
  • 2021-05-17
  • 2022-12-23
  • 2021-05-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-30
猜你喜欢
  • 2022-02-18
  • 2022-12-23
  • 2022-12-23
  • 2021-07-21
  • 2022-12-23
  • 2022-12-23
  • 2021-06-09
相关资源
相似解决方案