demolaynyc 0 Report post Posted December 10, 2006 So I started taking a tutorial on PHP DOMXML which is said to be part of the PHP Core. However, when I tried it out in Xisto server (I used the exact script and file so I know it should work) It didn't work...Is DOM XML part of the PHP Core of Xisto because I see it in the phpinfo().Must I enable something in the php.ini file? Share this post Link to post Share on other sites
TavoxPeru 0 Report post Posted December 10, 2006 So I started taking a tutorial on PHP DOMXML which is said to be part of the PHP Core. However, when I tried it out in Xisto server (I used the exact script and file so I know it should work) It didn't work...Is DOM XML part of the PHP Core of Xisto because I see it in the phpinfo().Must I enable something in the php.ini file?Yes it is part of the PHP Core as you see it in the phpinfo() result page, also you dont need to enable anything in the php.ini file.Now, this extension should no longer be used instead the official php site recommends to use the DOM extension, that is the replacement for the DOM XML extension from PHP 4. Best regards, Share this post Link to post Share on other sites
demolaynyc 0 Report post Posted December 10, 2006 So, could someone please show me a script using PHP DOM because I tried that one too and still doesn't work. Share this post Link to post Share on other sites
demolaynyc 0 Report post Posted December 10, 2006 Ok, here's the code I tried: <?php# make an example xml document to play with$xmlstr = "<" . "?" . "xml version=\"1.0\"" . "?" . ">";$xmlstr .="<employee> <name>Matt</name> <position type=\"contract\">Web Guy</position></employee>";# load xml data ($doc becomes an instance of # the DomDocument object)$doc = xmldoc($xmlstr);# get root node "employee"$employee = $doc->root();# get employee's children ("name","position")$nodes = $employee->children();# let's play with the "position" node# so we must iterate through employee's# children in search of itwhile ($node = array_shift($nodes)){ if ($node->name == "position") { $position = $node; break; }}# get position's type attribute$type = $position->getattr("type");# get the text enclosed by the position tag# shift the first element off of position's children$text_node = array_shift($position->children());# access the content property of the text node$text = $text_node->content;# echo out the position and typeecho "position: $text<BR>";echo "type: $type";?> And this is the output I get when I load it:Warning: domdocument() expects at least 1 parameter, 0 given in /home/demnyc/public_html/dom.php on line 2Fatal error: Call to undefined function: load() in /home/demnyc/public_html/dom.php on line 3 Share this post Link to post Share on other sites