使用HTMLAgilityPack选择具有空格属性的节点

编程入门 行业动态 更新时间:2024-10-26 20:22:59
本文介绍了使用HTMLAgilityPack选择具有空格属性的节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试从以下选项中选择所有li元素:

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>

我正在使用以下XPath查询,但这不会返回任何内容.

I'm using the following XPath query but this returns nothing.

Dim result As HtmlNodeCollection = htmlDoc.DocumentNode.SelectNodes("//li[@class='third left']")

对空格的属性是否有不同的对待?使用此工具,XPath可以正常工作.

Are attributes with spaces treated differently? Using this tool the XPath works correctly.

推荐答案

正如@SimonMourier所说,您的XPath是正确的.我建议您执行以下操作:

As @SimonMourier said, your XPath is correct. I suggest you doing the following:

  • 发布整个HTML源,并告诉我们是从文件中加载还是直接从Web加载

  • Posting the entire HTML source and telling us if you're loading it from a file or directly from the web

将htmlDoc.DocumentNode.OuterHtml的内容写入文本文件.如果您是从网络上加载HTML,则可能是 404 (找不到 )之类的东西;)

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 ;)

更多推荐

使用HTMLAgilityPack选择具有空格属性的节点

本文发布于:2023-11-05 19:41:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1561670.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:节点   空格   属性   HTMLAgilityPack

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!