using a form disigned with html i am collecting some data and saving them to an xml temp file. then i want to validate them with an xsd file in order to finally write them to save them to the ordinary file.
using the instruction below in the xml at root element, the file opens in the browser(valid)
Code: Select all
<SONGS xmlns ="http://www.songs.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.songs.org p06166.xsd"Code: Select all
$xdoc = new DomDocument;
$xmlfile = '123.xml';
$xmlschema = 'p06166.xsd';
//Load the xml document in the DOMDocument object
$xdoc->Load($xmlfile);
//Validate the XML file against the schema
if ($xdoc->schemaValidate($xmlschema)) {
print "Song inserted successfully!! <br />";
}
else {
print "$xmlfile is invalid.\n";
}the error i get is the one below. do you have any idea why i get error, since the input is valid???
Warning: DOMDocument::schemaValidate() [domdocument.schemavalidate]: Element 'SONGS': No matching global declaration available for the validation root. in C:\xampp\htdocs\test.php on line 48
123.xml is invalid.