Parse an XML response from the validator.
This function parses a SOAP 1.2 response XML string from the validator.
Parameters
string $xml: The raw SOAP 1.2 XML response from the validator.
Return value
array Info from the w3c server.
1 call to advagg_validator_parse_soap_response_w3c()
- advagg_validator_test_css_file_w3c in advagg_validator/
advagg_validator.inc - Given a CSS file, test to make sure it is valid CSS.
File
-
advagg_validator/
advagg_validator.inc, line 202
Code
function advagg_validator_parse_soap_response_w3c($xml) {
$doc = new DOMDocument();
$response = array();
// Try to load soap 1.2 XML response, and suppress warning reports if any.
if (!@$doc->loadXML($xml)) {
// Could not load the XML document.
return $response;
}
// Get the standard CDATA elements.
$cdata = array(
'uri',
'checkedby',
'csslevel',
'date',
);
foreach ($cdata as $var) {
$element = $doc->getElementsByTagName($var);
if ($element->length) {
$response[$var] = $element->item(0)->nodeValue;
}
}
// Handle the element validity and get errors if not valid.
$element = $doc->getElementsByTagName('validity');
if ($element->length && $element->item(0)->nodeValue === 'true') {
$response['validity'] = TRUE;
}
else {
$response['validity'] = FALSE;
$errors = $doc->getElementsByTagName('error');
foreach ($errors as $error) {
$response['errors'][] = advagg_validator_dom_extractor($error);
}
}
// Get warnings.
$warnings = $doc->getElementsByTagName('warning');
foreach ($warnings as $warning) {
$response['warnings'][] = advagg_validator_dom_extractor($warning);
}
// Return response array.
return $response;
}