validate xml against xsd file provided
/** * validateXmlAgainstXsd * function to validate xml against xsd file provided * @param string $error error * @return string api response * @access public */ public static function validateXmlAgainstXsd($sXmlPath,$sXsdPath) { // Enable user error handling libxml_use_internal_errors(true); $xml = new DOMDocument(); $xml->load($sXmlPath); if (!$xml->schemaValidate($sXsdPath)) { $aError =self::libxml_display_errors(); $iError=1; } else { $iError=0; } return array($iError,$aError); } Example of XSD file: <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:annotation> <xs:documentation xml:lang="en"> Job specification schema for scheduler.vubites.com Copyright 2010 satishgaudo.com. All rights reserved. </xs:documentation> </xs:annotation> <xs:element name="response" type="responseType"/> <xs:complexType name="responseType"> <xs:sequence> <xs:element name="status" maxOccurs="1" type="xs:string"></xs:element> <xs:element name="remark" maxOccurs="1" type="xs:string"></xs:element> <xs:element name="statuscode" maxOccurs="1" type="xs:int"></xs:element> <xs:element name="mashid" maxOccurs="1" type="xs:string"></xs:element> <xs:element name="channel_id" maxOccurs="1" type="xs:int"></xs:element> <xs:element name="profile_id" minOccurs="1" maxOccurs="1" type="xs:int"></xs:element> <xs:element name="md5checksum" minOccurs="0" type="xs:string"></xs:element> </xs:sequence> </xs:complexType> </xs:schema> Example of valid xml file: <?xml version="1.0" encoding="UTF-8"?> <response> <status><![CDATA[Success]]></status> <remark><![CDATA[MD5 ckecksum]]></remark> <statuscode><![CDATA[58]]></statuscode> <mashid><![CDATA[e3f03946968bc172d6e00c93a760d0c4]]></mashid><channel_id><![CDATA[10]]></channel_id> <profile_id><![CDATA[1]]></profile_id> <md5checksum><![CDATA[6f14e5acafa546495261adbd95f4a541]]></md5checksum> </response>
Categories: PHP
http://extjs.com/forum/member.php?u=79374 guitar lessons
complex post. due one detail where I contest with it. I am emailing you in detail.
What a nice site, been surfing on it for the whole night and day and i neva got bored for a single minute. Keep up your good work and all of the best in everything you do!
please review my first site http://dvdclubadult.com/ – here – http://dvdclubadult.com/
Apologize for my bad english, I over its a winsome piece of your writing. Kind-heartedly I be suffering with faced alot of difficulties in this train but your article will definately escape me in future. Thank You
Hello from Russia!
Can I quote a post in your blog with the link to you?