加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – DOMDocument-> documentURI属性的目的是什么?

发布时间:2020-12-13 17:04:50 所属栏目:PHP教程 来源:网络整理
导读:这里是文档链接: http://php.net/manual/en/class.domdocument.php#domdocument.props.documenturi 但我不明白这个设置是否为此对象显示的值,或者是用户可以更改的此设置? 这个值对loadHTML metod的html解析有什么影响吗?它可以用于绝对解析文档中的所有
这里是文档链接: http://php.net/manual/en/class.domdocument.php#domdocument.props.documenturi

但我不明白这个设置是否为此对象显示的值,或者是用户可以更改的此设置?

这个值对loadHTML metod的html解析有什么影响吗?它可以用于绝对解析文档中的所有相对链接吗?

解决方法

好的,我希望我能正确解释一下.

以下是documentUri的W3C DOM Interface specification:

documentURI of type DOMString,introduced in DOM Level 3

The location of the document or null if undefined or if the Document was created using DOMImplementation.createDocument. No lexical checking is performed when setting this attribute; this could result in a null value returned when using Node.baseURI.

Beware that when the Document supports the feature “HTML” [DOM Level 2 HTML],the href attribute of the HTML BASE element takes precedence over this attribute when computing Node.baseURI.

这对你意味着什么?

But I do not understand is this setting a value that this object reveal,or is this setting that user can change ?

它是文档的URI.如果您加载远程URI(例如此页面),它将包含远程URI,例如当前显示在浏览器地址栏中的网址.该值是公共的,因此它是可写的.

Has this value any effect on html parsing by loadHTML metod?

从理论上讲,是的.实际上,这取决于你的DOMImplementation has the HTML 2.0 feature.

Can it by used to absolutize all relative links in parsed document?

不是自动的.但是你可以使用它将它手动添加到以路径开头的任何链接.当然,您需要实现逻辑来检查是否需要自己扩展href值.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读