Load and Output XML
We want to initialize the XML parser, load the xml, and output it:
Example
$xmlDoc = new DOMDocument();
$xmlDoc->load("note.xml");
print $xmlDoc->saveXML();
?>
The output of the code above will be:
Tove Jani Reminder Don't forget me this weekend!
If you select "View source" in the browser window, you will see the following HTML:
Tove
Jani
Reminder
Don't forget me this weekend!
The example above creates a DOMDocument-Object and loads the XML from "note.xml" into it.
Then the saveXML() function to puts the internal XML document into a string, so we can output it.
|