PDA

View Full Version : XML DOM question


beetle
05-15-2003, 05:30 PM
hey all

I'm looking at the manual for XML DOM, but can't seem to find out if this is possible. I'd like to be able to add in a string of XML and unserialize it into nodes.

Possible?

mordred
05-15-2003, 09:51 PM
Yeah, I think that's possible. Have you looked at domxml_open_mem()? Here's a quick example:


$xmlstr = '
<test>
<node>Beer</node>
<node>Whiskey</node>
<node>Wine</node>
</test>
';

if(!$dom = domxml_open_mem($xmlstr)) {
echo "Error while parsing the document\n";
} else {
$root = $dom->document_element();
$nodes = $root->get_elements_by_tagname('node');
var_dump($nodes[2]->get_content());
}

beetle
05-15-2003, 10:55 PM
Ya - already found that - but thanks just the same.

I should have posted here that I found it. :rolleyes: