<?php
//makes a new DomDocument Object with version 1.0
$dom = new DomDocument(“1.0”);
//loads an XML Document from a string
$dom->loadXML(“<root/>”);
//loads an XML Document from the filesystem
$dom->load(“examples/books.xml”);
//sets output encoding
$dom->encoding=“iso-8859-1”;
//returns the XML Document as a string
print htmlspecialchars($dom->saveXML());
//would save it to a file
//print $dom->save(“filename.xml”);