Ask a Question
Advertise on boostr.in
adding a block of xml as child of a simplexmlelement object using -'php,xml,simplexml,add,simpledom'
adding a block of xml as child of a simplexmlelement object ¬†using -'php,xml,simplexml,add,simpledom'
I have this SimpleXMLElement object with a XML setup similar to the following...
$xml = <<<EOX
$sx = new SimpleXMLElement( $xml );
Now I have a class named Book that contains info. about each book. The same class can also spit out the book info. in XML format akin the the above (the nested ¬†block).. example,
$book = new Book( 'EFGH' );
... will generate
Now I'm trying to figure out a way by which I can use this generated XML block and append as a child of ¬†so that now it looks like... for example..
// Non-existent member method. For illustration purposes only.
$sx->addXMLChild( $book->genXML() ); ¬†¬†¬†
...XML tree now looks like:
From what documentation I have read on SimpleXMLElement, addChild() won't get this done for you as it doesn't support XML data as tag value.
Sep 7, 2015
to add a comment.
Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Email me if my answer is selected or commented on
Privacy: Your email address will only be used for sending these notifications.
To avoid this verification in future, please