I have a problem converting my string which has a structure of XML into a proper XML file.
My String looks like:
<product>
<ID>12345</ID>
<NAME></NAME>
</product>
<product>
<ID>123</ID>
<NAME></NAME>
</product>
And so on. The problem is that I get empty result if I use DOM.
$dom = new DomDocument('1.0', 'UTF-8');
$dom->loadXML($products);
$xml = $dom->saveXML($dom);
Output is:
string(39) "<?xml version="1.0" encoding="UTF-8"?>
"
How can I make this work? Or I just can add the html and root tags to this string and just parse it to the file?