XPATH

搜索innertext

node里搜索子node为什么不是再当前node内搜索,而是全文搜索。

By writing node.SelectSingleNode("//span[@itemprop='name']").InnerText it's like you writing doc.DocumentNode.SelectSingleNode("//span[@itemprop='name']").InnerText

To do what you want to do you should write it like this:node.SelectSingleNode(".//span[@itemprop='name']").InnerText. This dot tells make a search on the current node which is node instead on doc

表达式描述
nodename 选取此节点的所有子节点。
/ 从根节点选取。
// 从匹配选择的当前节点选择文档中的节点,而不考虑它们的位置。
. 选取当前节点。
.. 选取当前节点的父节点。
@ 选取属性。
原文地址:https://www.cnblogs.com/halou/p/3346087.html