Jump to content

Validate XML from Post


evdawg80

Recommended Posts

Stuck. Is this even possible? I'm trying to figure out a way for someone to upload an xml file via a PHP upload form and have the script run through the XML file and look for errors and spit them out (if any).  Basically, there will be items in the xml file like terms, inception date, etc.  An example of an error would be if the terms are over 84, then one of the errors should say, "Term over 84" and so on.

Link to comment
https://forums.phpfreaks.com/topic/97662-validate-xml-from-post/
Share on other sites

You have three options.

 

1) Manually do it (big pain)

2) XSD (my preference)

3) DTD (second choice)

 

XSD

Here is how to write a XSD Doc: http://www.w3schools.com/schema/

Then use DOMDocument->schemaValidate()

Check out this comment in particular: http://us2.php.net/manual/en/function.dom-domdocument-schemavalidate.php#62032

 

DTD

Here is how to write a DTD Doc: http://www.w3schools.com/dtd/

Add the DTD reference to the uploaded XML file

Then use DOMDocument->validate()

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.