View Full Version : DOM XML/DOM functions question

03-07-2007, 05:41 AM
With the DOM XML (http://us2.php.net/manual/en/ref.domxml.php) or DOM (http://us2.php.net/manual/en/ref.dom.php) functions, are you able to parse X/HTML documents as well as regular XML files? I've used these functions before, but only to read XML files.

Alternatively, can you create a DOM object from a string variable? Or do you have to open up and read a file (with the provided methods) before you can create a DOM object?

I did some poking around in the PHP manual and couldn't find answers to these questions.....Thanks.

03-07-2007, 08:54 AM
with the DOM classes in PHP5, you can use loadHTMLFile() or loadHTML() to load in html from a file or from an arbitrary html string respectively.

For loading an XML string, you can use the loadXML() function

03-07-2007, 09:52 AM
Great, thanks....do we have the same capabilities with the DOM XML functions, or is this a PHP 5 only privilege?

03-07-2007, 11:59 AM
no idea I'm afraid, I do all my work with 5 :|

03-07-2007, 04:42 PM
Look here: DOM Reference (http://www.php.net/manual/en/ref.dom.php).

03-08-2007, 12:03 PM
Thanks, I already looked through the manual regarding the DOM XM (http://www.php.net/manual/en/ref.domxml.php)L functions for PHP 4, and it doesn't look like they support that kind of thing (although, it seems that the only way to know for sure would be to try to open an HTML doc with DOM XML, and see if I can operate on the DOM)...just the DOM functions for PHP 5 do...

Depending on which server I'm using, it would be nice to have the same functionality for both PHP 4 and 5...

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum