alin19 Posted August 28, 2008 Share Posted August 28, 2008 i took the first script from here: http://www.php.net/dom and still geting an error: Warning: domdocument::domdocument() expects at least 1 parameter, 0 given in C:\xampp\htdocs\inv\verifica.php on line 28 Fatal error: Call to undefined method domdocument::loadXML() in C:\xampp\htdocs\inv\verifica.php on line 29 <?php // XML data $xml_string = "<?xml version='1.0' ?> <sentence> How to get contents of node with all tags by PHP Dom: <br/> <b>cabbages</b>, <i>tomatoes</i>, <i>apples</i>, <font color='purple'>aubergines</font> <ol> <li> row 1</li> <li> row 2 </li> <li> row 3 </li> </ol> <table border = '1'> <tbody> <tr> <td>I am best</td> </tr> <tr> <td>Programmer</td> </tr> </tbody> </table> You see my projects at: <strong><a href='http://www.itdeveloping.eu' >www.itdeveloping.eu</a></strong> </sentence>"; // parse it $doc= new DOMDocument(); if (!$doc->loadXML($xml_string)) { echo ("Error in XML document"); } $nody = $doc->getElementsByTagName('sentence'); // gets NodeList $nod=$nody->item(0);//Node getContent($Content,$nod); echo $Content; function getContent(&$NodeContent="",$nod) { $NodList=$nod->childNodes; for( $j=0 ; $j < $NodList->length; $j++ ) { $nod2=$NodList->item($j);//Node j $nodemane=$nod2->nodeName; $nodevalue=$nod2->nodeValue; if($nod2->nodeType == XML_TEXT_NODE) $NodeContent .= $nodevalue; else { $NodeContent .= "<$nodemane "; $attAre=$nod2->attributes; foreach ($attAre as $value) $NodeContent .="{$value->nodeName}='{$value->nodeValue}'" ; $NodeContent .=">"; getContent($NodeContent,$nod2); $NodeContent .= "</$nodemane>"; } } } ?> Link to comment https://forums.phpfreaks.com/topic/121664-domdocument-error/ Share on other sites More sharing options...
ratcateme Posted August 28, 2008 Share Posted August 28, 2008 try $doc= new DOMDocument('1.0'); Scott. Link to comment https://forums.phpfreaks.com/topic/121664-domdocument-error/#findComment-627656 Share on other sites More sharing options...
alin19 Posted August 28, 2008 Author Share Posted August 28, 2008 i'm still geting errors: Warning: domdocument::domdocument() [domdocument.domdocument]: Entity: line 1: parser error : Start tag expected, '<' not found in C:\xampp\htdocs\inv\test.php on line 3 Warning: domdocument::domdocument() [domdocument.domdocument]: 1.0 in C:\xampp\htdocs\inv\test.php on line 3 Warning: domdocument::domdocument() [domdocument.domdocument]: ^ in C:\xampp\htdocs\inv\test.php on line 3 Fatal error: Call to undefined method domdocument::saveXML() in C:\xampp\htdocs\inv\test.php on line 5 i've tryed to Comment out the [php_DOMXML] part in the PHP.ini file, same errors, Link to comment https://forums.phpfreaks.com/topic/121664-domdocument-error/#findComment-627663 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.