Html Agility Pack SelectSingleNode giving always same result in iteration?

前端 未结 1 1962
悲&欢浪女
悲&欢浪女 2020-12-31 04:40

I would like the nodes in the collection but with iterating SelectSingleNode I keep getting the same object just node.Id is changing... What i try is to readout the webrespo

相关标签:
1条回答
  • 2020-12-31 05:03

    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 / period tells make a search on the current node which is node instead on doc

    0 讨论(0)
提交回复
热议问题