muzafar Posted August 10, 2009 Share Posted August 10, 2009 Hi all, i am using PHP5 and create xml using dom object. code here! // create a new document $doc = new DOMDocument(); $root = $doc->createElement($_POST['cateName']); $root = $doc->appendChild($root); for($i=1;$i<=9;$i++) { $ti=$_POST[$i]; if( $_POST[$i] != '' ){ $ine = $_POST[$i]; $occ = $doc->createElement($ine); $occ = $root->appendChild($occ); $sub = $_REQUEST[$ti] ; $count = 0; foreach( @ $sub as $b) { $count ++; $child = $doc->createElement($ti.$count); $child = $occ->appendChild($child); $value = $doc->createTextNode("$b"); $value = $child->appendChild($value); } } } $xml_string = $doc->saveXML(); echo $xml_string; $doc->save("xmldata/".$id_image."_property.xml"); but give two error. Warning: domdocument::domdocument() expects at least 1 parameter, 0 given in www\htdocs\beopar\admin\classes\category.php on line 178 Fatal error: Call to undefined method domdocument::createElement() in www\htdocs\beopar\admin\classes\category.php on line 179 any know about this please reply me thankx Link to comment https://forums.phpfreaks.com/topic/169550-help-regarding-xml-writting-in-php/ Share on other sites More sharing options...
abazoskib Posted August 10, 2009 Share Posted August 10, 2009 DOMDocument(); requires a String as per its constructor Link to comment https://forums.phpfreaks.com/topic/169550-help-regarding-xml-writting-in-php/#findComment-894570 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.