views:

28

answers:

1

here is link to documentation: http://php.net/manual/en/class.domdocument.php#domdocument.props.documenturi

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

Has this value any effect on html parsing by loadHTML metod ? Can it by used to absolutize all relative links in parsed document ?

+2  A: 

Okay, I hope I explain that correctly.

Following is the W3C DOM Interface specification for documentUri:

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.

What does that mean for you?

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

It is the URI of the document. If you load a remote URI, like for instance this page, it will contain the remote URI, e.g. the URL currently shown in your browser address bar. The value is public, so it is writable.

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

In theory, yes. Practically, it depends on if your DOMImplementation has the HTML 2.0 feature.

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

Not automatically. But you can very much use it to prepend it manually to any links starting with a path. Of course you need to implement the logic to check whether the href value needs to be expanded yourself.

Gordon