I have a xml export that needs to be filtered before it can be imported.
So I wrote code to load, filter and save it.
$xml = simplexml_load_file('test.xml');
$nodes = $xml->xpath('/nodes/node[ ... condition ... ]');
$nodes->asXML('filtred.xml');
But I saw that asXML()
is a SimpleXMLElement::function
and that is an object of SimpleXMLElement
elements.
How can I group all the $nodes
in a general SimpleXMLElement
element to use asXML()
on it?
The original XML structure is:
<nodes>
<node>
<Titolo>Acquisti</Titolo>
<Corpo></Corpo>
<Nid>450</Nid>
</node>
...
</nodes>