【发布时间】:2010-08-22 21:17:14
【问题描述】:
我正在使用 libxml2 解析 HTML,使用 XPath 来查找元素。一旦我找到我正在寻找的元素,我如何才能从该元素中获取 HTML 作为字符串(请记住,该元素将有许多子元素)。给定一个文件:
<html>
<header>
<title>Some document</title>
</header
<body>
<p id="faq">
Some kind of text <a href="http://www.nowhere.com/">here</a>.
</p>
</body>
</html>
假设我使用 XPath 检索了 body 元素,然后获取了它的 HTML,我希望得到一个包含以下内容的字符串:
<body>
<p id="faq">
Some kind of text <a href="http://www.nowhere.com/">here</a>.
</p>
</body>
我该怎么做?
【问题讨论】:
标签: html c html-parsing libxml2