2

I need to use an XSD schema to develop a Web Service that receive reservations from an Hotel. I've the url of the xsd. This is the OTA_HotelResNotifRQ.

I don't know how to begin with this. Someone can help me?

Thanks

user1119732
  • 23
  • 1
  • 4
  • Could you already download the XSD file? – hakre Dec 28 '11 at 18:52
  • 2
    There are two questions which might help you: ["Parse XML using a XSD in PHP"](http://stackoverflow.com/questions/3244563/parse-xml-using-a-xsd-in-php) and ["generate PHP classes from XSD?"](http://stackoverflow.com/questions/2263771/generate-php-classes-from-xsd). XSD's can be used to validate a given XML file and it allows the mapping of XML files to ordinary (PHP/Java/whatever) objects. – vstm Dec 28 '11 at 18:57

1 Answers1

7

The PHP DOM extension, which is available almost all the time can do this natively.

$dom = new DomDocument;
$dom->loadXML($contentOfResponse);
if ($dom->schemaValidate('path/to/schema.xsd')) {
    // Valid response from service
} else {
    // Invalid response
}

Of course, you can also load the document to validate from a file.

Documentation: http://ca.php.net/manual/en/domdocument.schemavalidate.php

Louis-Philippe Huberdeau
  • 5,341
  • 1
  • 19
  • 22