aspnetguy Posted November 8, 2006 Share Posted November 8, 2006 Ok so I am creating an app that uses XML to store the data. I have also created Schemas for the XML file sto follow.I have found lots of articles on how to read in the XML with PHP but how do I compare the XML I am reading and creating to the Schema to ensure it is following the rules? Link to comment Share on other sites More sharing options...
boen_robot Posted November 8, 2006 Share Posted November 8, 2006 Actually the term is "check/validate against", not "compare" for obvious reasons .This article shows a simple function for that in PHP5.So, I think this should work as a simple errorless validator, though I haven't tested it: <?php$dom = new DomDocument();$dom->load("test.xml");if ($dom->schemaValidate('schema.xsd') === FALSE) {echo "Invalid XML document";}else {echo "VALID XML document";}?> Every other action that is XML realated uses other DOM functions. Be sure to check them out. Link to comment Share on other sites More sharing options...
aspnetguy Posted November 8, 2006 Author Share Posted November 8, 2006 thanks, is there a method for PHP4 or will I have to upgrade? Link to comment Share on other sites More sharing options...
boen_robot Posted November 8, 2006 Share Posted November 8, 2006 thanks, is there a method for PHP4 or will I have to upgrade?PHP4 has equivalent DOM XML functions but I don't think a Schema validation is among the supported objects. You'll have to upgrade. Link to comment Share on other sites More sharing options...
aspnetguy Posted November 8, 2006 Author Share Posted November 8, 2006 thanks very much...I guess I got some work to do before I can get to work Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now