I'm trying to select all the li
elements in from the following:
<div>
<ul>
<li 开发者_运维问答class="third left">
...
</li>
<li class="third left">
...
</li>
</ul>
</div>
I'm using the following XPath query but this returns nothing.
Dim result As HtmlNodeCollection = htmlDoc.DocumentNode.SelectNodes("//li[@class='third left']")
Are attributes with spaces treated differently? Using this tool the XPath works correctly.
As @SimonMourier said, your XPath is correct. I suggest you doing the following:
Posting the entire HTML source and telling us if you're loading it from a file or directly from the web
Writing in a text file the content of
htmlDoc.DocumentNode.OuterHtml
into a text file. If you're loading the HTML from the web, maybe you're getting a 404 (Not Found) or something ;)
精彩评论