curl-and-php
Sending a XML using Curl
Date: Wed, 12 Nov 2008 14:01:30 +0500
validate your xml with service provider XSD or DTD. You are getting response
from their server means your script is working. Your xml schema is wrong.
You must validate your xml packat with their XSD or DTD. For more
information check / consult the service provider. They always give out their
XSD. Even you can use PHP to validate your xml against their xsd.
I was working with Ebay Motors Pro API recently and I used the following
code for validation
function libxml_display_error($error)
{
$return = "<br/>\n";
switch ($error->level) {
case LIBXML_ERR_WARNING:
$return .= "<b>Warning $error->code</b>: ";
break;
case LIBXML_ERR_ERROR:
$return .= "<b>Error $error->code</b>: ";
break;
case LIBXML_ERR_FATAL:
$return .= "<b>Fatal Error $error->code</b>: ";
break;
}
$return .= trim($error->message);
if ($error->file) {
$return .= " in <b>$error->file</b>";
}
$return .= " on line <b>$error->line</b>\n";
return $return;
}
function libxml_display_errors() {
$errors = libxml_get_errors();
foreach ($errors as $error) {
print libxml_display_error($error);
}
libxml_clear_errors();
}
// Enable user error handling
libxml_use_internal_errors(true);
$xml = new DOMDocument();
$xml->load('i1-13s.xml');
if (!$xml->schemaValidate('schema.xsd')) {
print '<b>DOMDocument::schemaValidate() Generated Errors!</b>';
libxml_display_errors();
}
else {
echo "validated";
}
Haroon Ahmad
PHP Web Developer
www.haroonahmad.co.uk
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2008-11-12