Thread: Php xml dom
View Single Post
  #4  
Old 05-04-2009, 06:00 PM
welcomewiki welcomewiki is offline
Member
 
Join Date: Dec 2008
Location: India
Posts: 80,567
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.
Reply With Quote