I have an XML file (example below) and it is sitting somewhere on the net. When I import it using SimpleXML like so $sXML = @simplexml_load_file( $url );, the contents of the files are converted in the simple XMl objects.
<?xml version="1.0" encoding="UTF-8"?>
<title>Test</title>
<description>Test Description</description>
<item id="500">
<title>Item Title</title>
<description>Item Description</description>
</item>
<item id="501">
<title>Item Title</title>
<description>Item Description</description>
</item>
I would like to add a new set of parents. One at root level and the other that contains "item" so that it looks like the XML file below:
<?xml version="1.0" encoding="UTF-8"?>
<data>
<title>Test</title>
<description>Test Description</description>
<content>
<item id="500">
<title>Item Title</title>
<description>Item Description</description>
</item>
<item id="501">
<title>Item Title</title>
<description>Item Description</description>
</item>
</content>
</data>
How is this possible using SimpleXML or any other way?
Thanks for all the help.
@, the error was suppressed. The mute operator should pretty much never be used, and especially not during development.