Sunday, 15 July 2012

XML / PHP : Creation of a XML text with PHP -



XML / PHP : Creation of a XML text with PHP -

i'm beginner xml on php. page returns me next php error:

but, @ line 2, there "require_once", followed 3 others "require_once", path required file ok, , ends ';'. line above "

i have sample of code, think source of error (in order)

$xml = simplexml_load_string("<result/>"); $entitlements = $xml->addchild("entitlements"); $entitlements->addchild("productid", $productid);

then, below :

$fulfillmentxml = new simplexmlelement($result); //some stuff $fullfillmentxml echo $xml->asxml();

i not understand how xml works in php, thought there problem creating simplexmlelement() after simplexml_load_string() call.

your error doesn't php error, rather browser error generated when tried parse supplied xml contents. hence line 2 of error not refer line 2 of php file, line 2 of generated output.

check output (source of generated page), , see line 2 there. create sure have 1 root element, , nil comes after it.

php xml

No comments:

Post a Comment