Error on line 2 at column 1: Extra content at the end of the document

1

Hello, everyone, I'm trying to create an xml, but it returns the error of the title, I searched google and everything I saw about that was missing root, however, I believe I'm using root, can you help me?

$valorReal = 340.00;
$dom = new DomDocument("1.0", "ISO-8859-1");
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$root = $dom->createElement("AUTORIZACAO");
$total = $dom->createElement("TOTAL", $valorReal);
$root->appendChild($total);
$dom->appendChild($root);

header("Content-Type: text/xml");
echo "<xmp>" . $dom->saveXML() . "</xmp>";

Edit: Other suggestions for creating an xml also suit me:)

    
asked by anonymous 28.12.2016 / 14:12

1 answer

1

Hello, the problem seems to be that "xmp" root tag that you concatenate from outside XML ... I also did not understand what it means.

Testing in Firefox here, it looks like this:

Just remove that strange tag xmp that the XML is correct; -)

    
28.12.2016 / 14:44