Ver Mensaje Individual
  #1 (permalink)  
Antiguo 24/03/2010, 16:24
Avatar de lisandro Arg
lisandro Arg
 
Fecha de Ingreso: octubre-2003
Ubicación: Cordoba, Argentina
Mensajes: 945
Antigüedad: 20 años, 6 meses
Puntos: 24
Guardar un XML externo

Hola a todos !

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
  1. $geoNameCountries = new  Zend_Rest_Client('http://ws.geonames.org/countryInfo?continentCode=eu&lang=es');
  2. $resultCountries = $geoNameCountries->get();
  3. Zend_Debug::dump($resultGeonames);

Y el resultado es:
Código HTML:
Ver original
  1. object(Zend_Rest_Client_Result)#246 (1) {
  2.   ["_sxml:protected"] => object(SimpleXMLElement)#250 (1) {
  3.     ["country"] => array(57) {
  4.       [0] => object(SimpleXMLElement)#245 (16) {
  5.         ["countryCode"] => string(2) "AO"
  6.         ["countryName"] => string(6) "Angola"
  7.         ["isoNumeric"] => string(2) "24"
  8.         ["isoAlpha3"] => string(3) "AGO"
  9.         ["fipsCode"] => string(2) "AO"
  10.         ["continent"] => string(2) "AF"
  11.         ["capital"] => string(6) "Luanda"
  12.         ["areaInSqKm"] => string(9) "1246700.0"
  13.         ["population"] => string(8) "12531000"
  14.         ["currencyCode"] => string(3) "AOA"
  15.         ["languages"] => string(5) "pt-AO"
  16.         ["geonameId"] => string(7) "3351879"
  17.         ["bBoxWest"] => string(15) "11.679217338562"
  18.         ["bBoxNorth"] => string(16) "-4.3768253326416"
  19.         ["bBoxEast"] => string(16) "24.0821228027344"
  20.         ["bBoxSouth"] => string(17) "-18.0420780181885"
  21.       }
  22.       [1] => object(SimpleXMLElement)#253 (16) {
  23.         ["countryCode"] => string(2) "BF"
  24.         ["countryName"] => string(12) "Burkina Faso"
  25.         ["isoNumeric"] => string(3) "854"
  26.         ["isoAlpha3"] => string(3) "BFA"
  27.         ["fipsCode"] => string(2) "UV"
  28.         ["continent"] => string(2) "AF"
  29.         ["capital"] => string(9) "Uagadugú"
  30.         ["areaInSqKm"] => string(8) "274200.0"
  31.         ["population"] => string(8) "14761000"
  32.         ["currencyCode"] => string(3) "XOF"
  33.         ["languages"] => string(5) "fr-BF"
  34.         ["geonameId"] => string(7) "2361809"
  35.         ["bBoxWest"] => string(17) "-5.51891660690308"
  36.         ["bBoxNorth"] => string(15) "15.082594871521"
  37.         ["bBoxEast"] => string(16) "2.40539526939392"
  38.         ["bBoxSouth"] => string(16) "9.40110683441162"
  39.       }
  40.       [2] => object(SimpleXMLElement)#252 (16) {
  41.         ["countryCode"] => string(2) "BI"
  42.         ["countryName"] => string(7) "Burundi"
  43.         ["isoNumeric"] => string(3) "108"
  44.         ["isoAlpha3"] => string(3) "BDI"
  45.         ["fipsCode"] => string(2) "BY"
  46.         ["continent"] => string(2) "AF"
  47.         ["capital"] => string(9) "Bujumbura"
  48.         ["areaInSqKm"] => string(7) "27830.0"
  49.         ["population"] => string(7) "8691000"
  50.         ["currencyCode"] => string(3) "BIF"
  51.         ["languages"] => string(8) "fr-BI,rn"
  52.         ["geonameId"] => string(6) "433561"
  53.         ["bBoxWest"] => string(16) "28.9930572509766"
  54.         ["bBoxNorth"] => string(17) "-2.31012272834778"
  55.         ["bBoxEast"] => string(16) "30.8477325439453"
  56.         ["bBoxSouth"] => string(17) "-4.46571350097656"
  57.       }
  58.       [3] => object(SimpleXMLElement)#255 (16) {
  59.         ["countryCode"] => string(2) "BJ"
  60.         ["countryName"] => string(6) "Benín"
  61.         ["isoNumeric"] => string(3) "204"
  62.         ["isoAlpha3"] => string(3) "BEN"
  63.         ["fipsCode"] => string(2) "BN"
  64.         ["continent"] => string(2) "AF"
  65.         ["capital"] => string(10) "Porto-Novo"
  66.         ["areaInSqKm"] => string(8) "112620.0"
  67.         ["population"] => string(7) "8294000"
  68.         ["currencyCode"] => string(3) "XOF"
  69.         ["languages"] => string(5) "fr-BJ"
  70.         ["geonameId"] => string(7) "2395170"
  71.         ["bBoxWest"] => string(17) "0.774574935436249"
  72.         ["bBoxNorth"] => string(16) "12.4183483123779"
  73.         ["bBoxEast"] => string(16) "3.85170125961304"
  74.         ["bBoxSouth"] => string(16) "6.22574710845947"
  75.       }
  76.      
  77. ........
  78.  
  79.       [55] => object(SimpleXMLElement)#307 (16) {
  80.         ["countryCode"] => string(2) "ZM"
  81.         ["countryName"] => string(6) "Zambia"
  82.         ["isoNumeric"] => string(3) "894"
  83.         ["isoAlpha3"] => string(3) "ZMB"
  84.         ["fipsCode"] => string(2) "ZA"
  85.         ["continent"] => string(2) "AF"
  86.         ["capital"] => string(6) "Lusaka"
  87.         ["areaInSqKm"] => string(8) "752614.0"
  88.         ["population"] => string(8) "11669000"
  89.         ["currencyCode"] => string(3) "ZMK"
  90.         ["languages"] => string(28) "en-ZM,bem,loz,lun,lue,ny,toi"
  91.         ["geonameId"] => string(6) "895949"
  92.         ["bBoxWest"] => string(16) "21.9993686676025"
  93.         ["bBoxNorth"] => string(17) "-8.22435855865479"
  94.         ["bBoxEast"] => string(16) "33.7057113647461"
  95.         ["bBoxSouth"] => string(16) "-18.079475402832"
  96.       }
  97.       [56] => object(SimpleXMLElement)#308 (16) {
  98.         ["countryCode"] => string(2) "ZW"
  99.         ["countryName"] => string(8) "Zimbabue"
  100.         ["isoNumeric"] => string(3) "716"
  101.         ["isoAlpha3"] => string(3) "ZWE"
  102.         ["fipsCode"] => string(2) "ZI"
  103.         ["continent"] => string(2) "AF"
  104.         ["capital"] => string(8) "Harareen"
  105.         ["areaInSqKm"] => string(8) "390580.0"
  106.         ["population"] => string(8) "12382000"
  107.         ["currencyCode"] => string(3) "ZWL"
  108.         ["languages"] => string(14) "en-ZW,sn,nr,nd"
  109.         ["geonameId"] => string(6) "878675"
  110.         ["bBoxWest"] => string(15) "25.237024307251"
  111.         ["bBoxNorth"] => string(17) "-15.6088333129883"
  112.         ["bBoxEast"] => string(16) "33.0563125610352"
  113.         ["bBoxSouth"] => string(17) "-22.4177417755127"
  114.       }
  115.     }
  116.   }
  117. }