Jump to content

help regarding xml writting in php


muzafar

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.