我目前正在尝试解析一个HTML文档,以检索其中所有的脚注;该文档包含了许多这样的脚注。我无法弄清楚要使用哪些表达式来提取我想要的所有内容。问题在于,类(例如“calibre34”)在每个文档中都是随机的。唯一找到脚注位置的方法是搜索“hide”,然后它总是跟着文本,并用< /td>标签关闭。下面是HTML文档中一个脚注的示例,我只想要文本。有什么想法吗?谢谢大家!
<td class="calibre33">1.<span><a class="x-xref" href="javascript:void(0);">
[hide]</a></span></td>
<td class="calibre34">
Among the other factors on which the premium would be based are the
average size of the losses experienced, a margin for contingencies,
a loading to cover the insurer's expenses, a margin for profit or
addition to the insurer's surplus, and perhaps the investment
earnings the insurer could realize from the time the premiums are
collected until the losses must be paid.</td>
x-ref
类的a
标签并获取最近的td
父元素? - Peter OlsonXDocument
(XML to LINQ) 或XmlDocument
(POCO) 来解析你的 HTML。这两个 XML 库已经包含在 .NET/C# 中,非常强大。 - qJake