xPath 不检索 HTML 作为所需内容的一部分 [英] xPath doesn't retrieve HTML as part of what is needed

查看:27
本文介绍了xPath 不检索 HTML 作为所需内容的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能的重复:
xPath 不检索 HTML 作为内容的一部分

我在 xPath 的帮助下解析网页并检索 div 元素的内容,它省略了该 div 元素中包含的 HTML.如何让它检索包含 HTML 的 div 元素的全部内容?

I parse a web page with the help of xPath and retrieving the content of the div element, it omits HTML that is contained in that div element. How to make it retrieve the whole content of the div element with HTML included?

推荐答案

如果这是在 Javascript 中,我只想说使用 .innerHTML 属性,它将检索所有内容的全部内容任何给定节点.但是由于您使用的是 PHP,因此没有这样的功能.

If this were in Javascript, I'd just say use the .innerHTML attribute, which would retrieve all the entirety of the contents of any given node. But since you're on PHP, there's no such function.

但是,您可以伪造它,详情如下:http://www.dynamit.us/blog/2009/03/php-dom-innerhtml-method/

You can fake it, however, as detailed here: http://www.dynamit.us/blog/2009/03/php-dom-innerhtml-method/

这篇关于xPath 不检索 HTML 作为所需内容的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆