Parsing HTML Reading Option Tag Content with HtmlAgillityPack

前端 未结 3 750
旧巷少年郎
旧巷少年郎 2020-12-06 22:52

I am trying to use HtmlAgilityPack to parse HTML, but am having problems.

Sample HTML Doc:


  

        
3条回答
  •  感情败类
    2020-12-06 23:35

    Your XPath expression:

    //option
    

    It's an absolute path: it traverse all the tree starting from the root.

    You need a relative XPath expression:

    descendant::option
    

    Or the shorthand

    .//option
    

    Do note: this is the only case where to start a path with . (self::node() shorthand) is useful.

提交回复
热议问题