Reputation: 151
I want to be able to create a XML File, add nodes and such to it, then output it to the screen without saving.
$bookxml = new DOMDocument('1.0', 'utf-8');
is how i have the XML file created, however i just can't anyway to display the XML file on the screen without saving it.
However i am having a problem with outputting even in save, this is the line i have
echo $bookxml->save("testing.xml");
All this does is return the file size of the newly created XML, and not the contents.
Any help would be awesome, i'm completely stumped on this.
Upvotes: 0
Views: 987
Reputation: 97672
What you're looking for is saveXML, additionally you can use htmlspecialchars to encode the xml so you can see it in your browser display.
echo htmlspecialchars($bookxml->saveXML());
Upvotes: 4
Reputation: 12419
You want the saveXML
method, not the save
method:
https://www.php.net/manual/en/domdocument.savexml.php
Upvotes: 0