Foros del Web » Programando para Internet » PHP »

FUNCION XML2Array

Estas en el tema de FUNCION XML2Array en el foro de PHP en Foros del Web. Buenas, tengo el siguiente problema Utilizo la funcion creada x: /** * xml2array() will convert the given XML text to an array in the XML ...
  #1 (permalink)  
Antiguo 11/04/2012, 13:07
 
Fecha de Ingreso: diciembre-2005
Mensajes: 87
Antigüedad: 18 años, 4 meses
Puntos: 3
Exclamación FUNCION XML2Array

Buenas, tengo el siguiente problema

Utilizo la funcion creada x:

/**
* xml2array() will convert the given XML text to an array in the XML structure.
* Link: http://www.bin-co.com/php/scripts/xml2array/
*/


Al obtener el XML

Código:
<xml_api_reply version="1">
<weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1" row="0" section="0">
<forecast_information>
<city data="Buenos Aires, Ciudad Autónoma de Buenos Aires"/>
<postal_code data="Buenos Aires Argentina"/>
<latitude_e6 data=""/>
<longitude_e6 data=""/>
<forecast_date data="2012-04-11"/>
<current_date_time data="1970-01-01 00:00:00 +0000"/>
<unit_system data="SI"/>
</forecast_information>
<current_conditions>
<condition data="Neblina"/>
<temp_f data="73"/>
<temp_c data="23"/>
<humidity data="Humedad: 72%"/>
<icon data="/ig/images/weather/haze.gif"/>
<wind_condition data="Viento: NE a 8 km/h"/>
</current_conditions>
<forecast_conditions>
<day_of_week data="mié"/>
<low data="17"/>
<high data="26"/>
<icon data="/ig/images/weather/fog.gif"/>
<condition data="Niebla"/>
</forecast_conditions>
<forecast_conditions>
<day_of_week data="jue"/>
<low data="18"/>
<high data="24"/>
<icon data="/ig/images/weather/fog.gif"/>
<condition data="Niebla"/>
</forecast_conditions>
<forecast_conditions>
<day_of_week data="vie"/>
<low data="18"/>
<high data="24"/>
<icon data="/ig/images/weather/fog.gif"/>
<condition data="Niebla"/>
</forecast_conditions>
<forecast_conditions>
<day_of_week data="sáb"/>
<low data="16"/>
<high data="23"/>
<icon data="/ig/images/weather/fog.gif"/>
<condition data="Niebla"/>
</forecast_conditions>
</weather>
</xml_api_reply>
Observamos que hay tildes, o ñ. Como hago para que cuando llame mediante file get contents al fichero XML

Código PHP:
$contents file_get_contents($url); 
Este me lo devuelva sin tildes o ñ?

Ya he probado con esto:

Código PHP:
function QuitarTildes($cadena) {
    
$no_permitidas= array ("á","é","í","ó","ú","Á","É","Í","Ó","Ú","ñ","À","Ã","Ì","Ò","Ù","Ù","à","è","ì","ò","ù","ç","Ç","â","ê","î","ô","û","Â","Ê","ÃŽ","Ô","Û","ü","ö","Ö","ï","ä","«","Ò","Ã","Ä","Ë"," ");

$permitidas= array ("a","e","i","o","u","A","E","I","O","U","n","N","A","E","I","O","U","a","e","i","o","u","c","C","a","e","i","o","u","A","E","I","O","U","u","o","O","i","a","e","U","I","A","E","%2C");

$texto str_replace($no_permitidas$permitidas ,$cadena);

return 
$texto;

sobre la variable $contents pero nada...

Alguien me enseña el camino ? =)
  #2 (permalink)  
Antiguo 12/04/2012, 10:41
 
Fecha de Ingreso: diciembre-2005
Mensajes: 87
Antigüedad: 18 años, 4 meses
Puntos: 3
Respuesta: FUNCION XML2Array

Al final lo solucione,

Código PHP:
$contents utf8_encode(file_get_contents($url)); 
Ya me lee todo el fichero XML y puedo trabajar son sus datos.

Etiquetas: funcion, variables
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 03:49.