Bueno... estoy verde con xml y tengo problemas para guardarlo en un archivo, el Web Services que estoy usando a veces se cae entonce la idea es ir guardando los xml que retorna en local, algo seguramente muy sencillo pero que me está costando demaciado.
El XML lo obtengo con Zend Framework pero puede ser de cualquier otra forma (file_get_contents() no se puede usar en el hosting)
Código PHP:
Ver original
$geoNameCountries = new Zend_Rest_Client('http://ws.geonames.org/countryInfo?continentCode=eu&lang=es'); $resultCountries = $geoNameCountries->get(); Zend_Debug::dump($resultGeonames);
Y el resultado es:
Código HTML:
Ver original
object(Zend_Rest_Client_Result)#246 (1) { ["_sxml:protected"] => object(SimpleXMLElement)#250 (1) { ["country"] => array(57) { [0] => object(SimpleXMLElement)#245 (16) { ["countryCode"] => string(2) "AO" ["countryName"] => string(6) "Angola" ["isoNumeric"] => string(2) "24" ["isoAlpha3"] => string(3) "AGO" ["fipsCode"] => string(2) "AO" ["continent"] => string(2) "AF" ["capital"] => string(6) "Luanda" ["areaInSqKm"] => string(9) "1246700.0" ["population"] => string(8) "12531000" ["currencyCode"] => string(3) "AOA" ["languages"] => string(5) "pt-AO" ["geonameId"] => string(7) "3351879" ["bBoxWest"] => string(15) "11.679217338562" ["bBoxNorth"] => string(16) "-4.3768253326416" ["bBoxEast"] => string(16) "24.0821228027344" ["bBoxSouth"] => string(17) "-18.0420780181885" } [1] => object(SimpleXMLElement)#253 (16) { ["countryCode"] => string(2) "BF" ["countryName"] => string(12) "Burkina Faso" ["isoNumeric"] => string(3) "854" ["isoAlpha3"] => string(3) "BFA" ["fipsCode"] => string(2) "UV" ["continent"] => string(2) "AF" ["capital"] => string(9) "Uagadugú" ["areaInSqKm"] => string(8) "274200.0" ["population"] => string(8) "14761000" ["currencyCode"] => string(3) "XOF" ["languages"] => string(5) "fr-BF" ["geonameId"] => string(7) "2361809" ["bBoxWest"] => string(17) "-5.51891660690308" ["bBoxNorth"] => string(15) "15.082594871521" ["bBoxEast"] => string(16) "2.40539526939392" ["bBoxSouth"] => string(16) "9.40110683441162" } [2] => object(SimpleXMLElement)#252 (16) { ["countryCode"] => string(2) "BI" ["countryName"] => string(7) "Burundi" ["isoNumeric"] => string(3) "108" ["isoAlpha3"] => string(3) "BDI" ["fipsCode"] => string(2) "BY" ["continent"] => string(2) "AF" ["capital"] => string(9) "Bujumbura" ["areaInSqKm"] => string(7) "27830.0" ["population"] => string(7) "8691000" ["currencyCode"] => string(3) "BIF" ["languages"] => string(8) "fr-BI,rn" ["geonameId"] => string(6) "433561" ["bBoxWest"] => string(16) "28.9930572509766" ["bBoxNorth"] => string(17) "-2.31012272834778" ["bBoxEast"] => string(16) "30.8477325439453" ["bBoxSouth"] => string(17) "-4.46571350097656" } [3] => object(SimpleXMLElement)#255 (16) { ["countryCode"] => string(2) "BJ" ["countryName"] => string(6) "Benín" ["isoNumeric"] => string(3) "204" ["isoAlpha3"] => string(3) "BEN" ["fipsCode"] => string(2) "BN" ["continent"] => string(2) "AF" ["capital"] => string(10) "Porto-Novo" ["areaInSqKm"] => string(8) "112620.0" ["population"] => string(7) "8294000" ["currencyCode"] => string(3) "XOF" ["languages"] => string(5) "fr-BJ" ["geonameId"] => string(7) "2395170" ["bBoxWest"] => string(17) "0.774574935436249" ["bBoxNorth"] => string(16) "12.4183483123779" ["bBoxEast"] => string(16) "3.85170125961304" ["bBoxSouth"] => string(16) "6.22574710845947" } ........ [55] => object(SimpleXMLElement)#307 (16) { ["countryCode"] => string(2) "ZM" ["countryName"] => string(6) "Zambia" ["isoNumeric"] => string(3) "894" ["isoAlpha3"] => string(3) "ZMB" ["fipsCode"] => string(2) "ZA" ["continent"] => string(2) "AF" ["capital"] => string(6) "Lusaka" ["areaInSqKm"] => string(8) "752614.0" ["population"] => string(8) "11669000" ["currencyCode"] => string(3) "ZMK" ["languages"] => string(28) "en-ZM,bem,loz,lun,lue,ny,toi" ["geonameId"] => string(6) "895949" ["bBoxWest"] => string(16) "21.9993686676025" ["bBoxNorth"] => string(17) "-8.22435855865479" ["bBoxEast"] => string(16) "33.7057113647461" ["bBoxSouth"] => string(16) "-18.079475402832" } [56] => object(SimpleXMLElement)#308 (16) { ["countryCode"] => string(2) "ZW" ["countryName"] => string(8) "Zimbabue" ["isoNumeric"] => string(3) "716" ["isoAlpha3"] => string(3) "ZWE" ["fipsCode"] => string(2) "ZI" ["continent"] => string(2) "AF" ["capital"] => string(8) "Harareen" ["areaInSqKm"] => string(8) "390580.0" ["population"] => string(8) "12382000" ["currencyCode"] => string(3) "ZWL" ["languages"] => string(14) "en-ZW,sn,nr,nd" ["geonameId"] => string(6) "878675" ["bBoxWest"] => string(15) "25.237024307251" ["bBoxNorth"] => string(17) "-15.6088333129883" ["bBoxEast"] => string(16) "33.0563125610352" ["bBoxSouth"] => string(17) "-22.4177417755127" } } } }