To retrieve data as xml without header using SIMPLEXMLELEMENT in php -


i trying output this-

<start> <sub1> <one>sam</one> </sub1> </start> 

for tried code-

<?php   include('db.php');  $xml = new simplexmlelement();  $abc = $xml->addchild('start'); $s = $abc->addchild('sub1'); $s->addchild('one','sam');  echo $xml->asxml();  ?> 

but not giving me output.instead giving me error. error follows- fatal error: uncaught exception 'exception' message 'simplexmlelement::__construct() expects @ least 1 parameter, 0 given' in d:\xamppnew\htdocs\_acct\trialxml.php:5 stack trace: #0 d:\xamppnew\htdocs\_acct\trialxml.php(5): simplexmlelement->__construct() #1 {main} thrown in d:\xamppnew\htdocs\_acct\trialxml.php on line 5

can guide me how retrieve xml without header using simplexmlelement in php or please let me know went wrong. in advance.

simplexml can not work empty document. need load document document element.

$start = new simplexmlelement('<start/>'); $s = $start->addchild('sub1'); $s->addchild('one','sam');  echo $xml->asxml(); 

Comments

Popular posts from this blog

javascript - Why Selenium can't find an element that is graphically visible -

java - How to compare two classes -

mysql - Gateway Timeout Error on Insert 70000 record using Hibernate in Java -