【发布时间】:2014-01-20 06:20:38
【问题描述】:
我有一个问题是如何使用 HTMLAgilityPack 来提取某些特定标签的 HTML 内容。 我提供以下 HTML 代码:
<td class="text_11" width="80%" valign="top">
<span class="text_11">Producer:</span>
<a class="link_11b" href="/Asus_producer.htm">Asus</a>
<br>
<p>
<table class="text_11" border="0" style="width: 100%;">
<tbody>
</table>
<p> </p>
</td>
实际上我需要做的是提取<td class="text_11" width="80%" valign="top"> 包含的HTML 代码(如此处所示),即使此<td> 内的标签越来越多。
我需要将此文本(即 HTML)保存到字符串中: `
<span class="text_11">Producer:</span>
<a class="link_11b" href="/Asus_producer.htm">Asus</a>
<br>
<p>
<table class="text_11" border="0" style="width: 100%;">
<tbody>
</table>
<p> </p>
` 谢谢。
【问题讨论】:
-
附注 - 您的 html 中有问题 - 没有关闭
tbody和br元素,最后一个p元素已关闭但未打开,表格也嵌套在段落中跨度>
标签: c# html html-agility-pack