【发布时间】:2014-03-17 09:29:51
【问题描述】:
我正在使用 HtmlAgilityPack,我需要在 Html 文档中找到一个短语。例如我有一个文件:
<!DOCTYPE html>
<html>
<body>
<h1>aaa Heading ilo araferi</h1>
Thats <p>My <b>first</b> paragraph.</p>
<p>My second paragraph.</p>
<p>My third paragraph.</p>
</body>
</html>
我想将"Thats <p>My <b>first</b> paragraph.</p>" 包裹在span 中。为此,我需要仅使用文本(无 html 标签)查找所有出现的事件。例如
这是我的第一段。
换句话说,我希望短语 Thats My first paragraph. 匹配 Thats <p>My <b>first</b> paragraph.</p>
问题是,我不知道如何为这个特定任务执行 XPath 查询。任何帮助将不胜感激。谢谢
【问题讨论】:
-
For that, I need to find all occurences with text??不清楚... -
谢谢。我更新了问题。我不是以英语为母语的人,给您带来的不便,我深表歉意:)
-
您不能在 HTML 中的 span 标签内包裹段落标签。请改用 div 标签。
标签: c# html xpath html-agility-pack