XML load 2-step
I had a module where I was previously loading and processing an xml file in one step using
simple_xml_load_file (URL of xml file)
But this stopped working and now throws a php warning of
Warning: simplexml_load_file() [function.simplexml-load-file]: http:// wrapper is disabled in the server configuration by allow_url_fopen=0
indicating that the f_open is being blocked now by our new hardened server configuration.
To get around the problem I used a 2-step solution
1) Use drupal_http_request() to get the xml page (available in D6 and D7)
$oXmlLoad = drupal_http_request('http://www.weather.gov/xml/current_obs/PANC.xml');
2) Use simplexml_load_string() to parse the data string and convert it into the same array that the load file method would have returned
$aXml_Data = simplexml_load_string($oXmlLoad ->data);
if when using simplexml_load_string you can not get at the @attributes object you need to use the attributes() function
foreach ($oObject->attributes() as $a => $b)
{
$aThis[$a] = $b;
}
$sKey_name = $aThis[key];
Key being the value of $a that you are trying to get.