【发布时间】:2012-06-15 05:42:07
【问题描述】:
我有一个 div,其中包含这样的段落标签
<div class="div_5">
<p>First Paragraph</p>
<p>Second Paragraph</p>
<p>Third Paragraph</p>
<p>Fourth Paragraph</p>
</div>
<div class="div_5">
<p>First Paragraph</p>
<p>Second Paragraph</p>
<p>Third Paragraph</p>
<p>Fourth Paragraph</p>
</div>
我需要使用htmlagiitypack获取所有段落文本的文本我试过这个,
Dim oPB As HAP.HtmlNodeCollection = doc.DocumentNode.SelectNodes("//div[@class='post-bodycopy clearfix']/child::text()/"]
For Each item As HAP.HtmlNode In oPB
debug.print(item.InnerText)
Next
每个 div 字符串的预期输出是
First Paragraph
Second Paragraph
Third Paragraph
Fourth Paragraph
但是我在返回的文本中得到了一些 html,有人可以帮我解决问题
【问题讨论】:
-
如果 p 包含 HTML(不在您的示例数据中),则内部文本将显示它。你期待什么?
-
是的 p 的 conytain html 在源代码中,但不在呈现的文本中。我能不能得到 p 之间的文本
.this text
标签: .net winforms parsing html-agility-pack