function update_parse_xml in Drupal 7
Parses the XML of the Drupal release history info files.
Parameters
$raw_xml: A raw XML string of available release data for a given project.
Return value
Array of parsed data about releases for a given project, or NULL if there was an error parsing the string.
1 call to update_parse_xml()
- _update_process_fetch_task in modules/
update/ update.fetch.inc - Processes a task to fetch available update data for a single project.
File
- modules/
update/ update.fetch.inc, line 388 - Code required only when fetching information about available updates.
Code
function update_parse_xml($raw_xml) {
try {
$xml = new SimpleXMLElement($raw_xml);
} catch (Exception $e) {
// SimpleXMLElement::__construct produces an E_WARNING error message for
// each error found in the XML data and throws an exception if errors
// were detected. Catch any exception and return failure (NULL).
return;
}
// If there is no valid project data, the XML is invalid, so return failure.
if (!isset($xml->short_name)) {
return;
}
$short_name = (string) $xml->short_name;
$data = array();
foreach ($xml as $k => $v) {
$data[$k] = (string) $v;
}
$data['releases'] = array();
if (isset($xml->releases)) {
foreach ($xml->releases
->children() as $release) {
$version = (string) $release->version;
$data['releases'][$version] = array();
foreach ($release
->children() as $k => $v) {
$data['releases'][$version][$k] = (string) $v;
}
$data['releases'][$version]['terms'] = array();
if ($release->terms) {
foreach ($release->terms
->children() as $term) {
if (!isset($data['releases'][$version]['terms'][(string) $term->name])) {
$data['releases'][$version]['terms'][(string) $term->name] = array();
}
$data['releases'][$version]['terms'][(string) $term->name][] = (string) $term->value;
}
}
}
}
return $data;
}