Get a specific option in HtmlAgilityPack?

后端 未结 3 1619
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-26 09:22

is possible get with HtmlAgilityPack a specific option? For example I\'ve a select like this:


                        
    
提交评论

  • 2021-01-26 10:22
    doc.DocumentNode.SelectSingleNode("//Select[@id='foo']//*[@selected='selected']");
    

    This should work but its giving a wider birth to get it by attempting to get the first node it finds of any Tag type at any depth within the select Tag that has a selected Attribute of selected value.

    0 讨论(0)
  • 2021-01-26 10:27

    if the html looks like this

    <option value="1" selected>2</option> 
    

    it should be like this

    doc.DocumentNode.SelectSingleNode("//Select[@id='foo']//*[@selected='']");
    
    0 讨论(0)
  • 提交回复
    热议问题