输入Html
<section id="article">
<p>Hey This is XXX</p>
</section>
我使用lxmlxpath提取数据
xpath_paragraph = '//section[@id="article"]/p//text()'
items = mydoc.xpath(xpath_paragraph)
我得到的结果是:
Hey This is XXX
预期结果:
<p>Hey This is XXX</p>
结果是可以理解的,我正在提取文本,我也尝试了node()。它也不起作用。我需要用标签提取数据。你知道吗
这应该对你有用
输出
如果要显式选择文本节点('//section[@id=“article”]/p//text()'),请尝试以下表达式
应该选择p元素
相关问题 更多 >
编程相关推荐