SimpleXML was introduced in PHP5, while XmlReader was enabled by default in version 5.1, so the first is probably the best way:
$struct = simplexml_load_string($xml);
$version = (string)$struct->project->latest_release->latest_release_version;
However, if you do not perform any other XML processing and do not want to maximize compatibility, you can simply rename the XML:
if(preg_match('/<latest_release_version>(.*?)<\\/latest_release_version>/', $xml, $matches)){
$version = $matches[1];
}
This is messy than the XML processing is correct, but probably faster and supported by almost all PHP installations.
source
share