I'm trying to fully validate an xml file which may be published by a user before it's fully published and live - it's basically somewhat like a sitemap.xml and it absolutely can't be published without being error-proof ( yes, I do have my own custom dtd for it as well ).
I was also thinking of implementing a storage system so it would store say, the last 2-3 versions just incase ( as it's a real high priority type of thing ).
Any tips?
Edit: Here's what I currently have but in some circumstances I believe it validated when the xml wasn't exactly valid:
$dom = new DOMDocument();
if ( $dom->load( $tempFileName ) ) {
if ( $dom->validate() ) {
echo '<p>XML is valid. Overwriting sitemap.xml.</p>';
file_put_contents( 'sitemap.xml', $sitemapXML->asXML() );
} else {
echo '<p>XML is not valid. Please correct.</p>';
}
}