Foros del Web » Programando para Internet » PHP »

Problemas con new SimpleXMLElement(file_get_contents($ruta), NULL, false)

Estas en el tema de Problemas con new SimpleXMLElement(file_get_contents($ruta), NULL, false) en el foro de PHP en Foros del Web. Hola muy buenas, Tengo este script: if ($sxe = new SimpleXMLElement(file_get_contents($ruta_PartNumbe r), NULL, false)) { if ($sxe->{'files.index'}->file['HighPic']) { $value = $sxe->{'files.index'}->file['HighPic']; subir_fotos($value,$id_articulos,$name_file=$id_ar ticulos,$acceso='rar'); } return; ...
  #1 (permalink)  
Antiguo 15/05/2012, 05:42
Avatar de syntex  
Fecha de Ingreso: noviembre-2002
Ubicación: Cataluña
Mensajes: 978
Antigüedad: 21 años, 5 meses
Puntos: 4
Problemas con new SimpleXMLElement(file_get_contents($ruta), NULL, false)

Hola muy buenas,

Tengo este script:

if ($sxe = new SimpleXMLElement(file_get_contents($ruta_PartNumbe r), NULL, false))
{
if ($sxe->{'files.index'}->file['HighPic'])
{
$value = $sxe->{'files.index'}->file['HighPic'];
subir_fotos($value,$id_articulos,$name_file=$id_ar ticulos,$acceso='rar');
}

return;

}

Y me tira este error:

Warning: file_get_contents(http://[email protected]/xml_s3/xml_se...output=metaxml) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error in /usr/home/xxxxx/xxxxx.es/web/ini_articulos.php on line 70

Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /usr/home/xxxxxx/xxxxx.es/web/ini_articulos.php:70 Stack trace: #0 /usr/home/xxxxxx/xxxxx.es/web/ini_articulos.php(70): SimpleXMLElement->__construct('', 0, false) #1 /usr/home/xxxxxx/xxxxx.es/web/ini_articulos.php(643): imagenes('CN047AE', 'HP', '1694', 'TINHPA01318') #2 {main} thrown in /usr/home/xxxxxx/xxxxx.es/web/ini_articulos.php on line 70

Ya que quiero evitar que me salga el mensaje del warning y continue con el script y no puedo, e incluido:

Código PHP:
ini_set("error_reporting",0);
ini_set("display_errors",0); 
__________________
------------------------------------------------
La paciencia es el rey de la ciencia
------------------------------------------------

  #2 (permalink)  
Antiguo 15/05/2012, 05:57
Avatar de syntex  
Fecha de Ingreso: noviembre-2002
Ubicación: Cataluña
Mensajes: 978
Antigüedad: 21 años, 5 meses
Puntos: 4
Respuesta: Problemas con new SimpleXMLElement(file_get_contents($ruta), NULL, false)

Le e puesto @file_get_contents($ruta_PartNumbe r)

Pero me tira:

Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /usr/home/xxxxxx/xxxxx.es/web/ini_articulos.php:70 Stack trace: #0 /usr/home/xxxxxx/xxxxx.es/web/ini_articulos.php(70): SimpleXMLElement->__construct('', 0, false) #1 /usr/home/xxxxxx/xxxxx.es/web/ini_articulos.php(643): imagenes('C13S015329', 'EPSON', '220', 'CINEPS01400') #2 {main} thrown in /usr/home/xxxxxx/xxxxx.es/web/ini_articulos.php on line 70
__________________
------------------------------------------------
La paciencia es el rey de la ciencia
------------------------------------------------

  #3 (permalink)  
Antiguo 15/05/2012, 06:41
Avatar de abimaelrc
Colaborador
 
Fecha de Ingreso: mayo-2009
Ubicación: En el planeta de Puerto Rico
Mensajes: 14.734
Antigüedad: 14 años, 11 meses
Puntos: 1517
Respuesta: Problemas con new SimpleXMLElement(file_get_contents($ruta), NULL, false)

Verifica que estés recibiendo data con el file_get_contents primero.
__________________
Verifica antes de preguntar.
Los verdaderos amigos se hieren con la verdad, para no perderlos con la mentira. - Eugenio Maria de Hostos
  #4 (permalink)  
Antiguo 15/05/2012, 09:13
Avatar de syntex  
Fecha de Ingreso: noviembre-2002
Ubicación: Cataluña
Mensajes: 978
Antigüedad: 21 años, 5 meses
Puntos: 4
Respuesta: Problemas con new SimpleXMLElement(file_get_contents($ruta), NULL, false)

los recibo correctamente. es como sí en ese momento saltase el warning pero no siempre, sólo a veces salta el warning.

no habría la manera de ocultarlo y seguir con el script ?
muchas gracias
__________________
------------------------------------------------
La paciencia es el rey de la ciencia
------------------------------------------------

  #5 (permalink)  
Antiguo 15/05/2012, 09:21
Avatar de abimaelrc
Colaborador
 
Fecha de Ingreso: mayo-2009
Ubicación: En el planeta de Puerto Rico
Mensajes: 14.734
Antigüedad: 14 años, 11 meses
Puntos: 1517
Respuesta: Problemas con new SimpleXMLElement(file_get_contents($ruta), NULL, false)

Hay muchas formas, una es usar error_reporting(0) y ini_set('display_errors', 0). Otra es usar ob_start y luego ob_get_clean luego de la conexión a la base de datos, algo como
Código PHP:
Ver original 
Etc...
__________________
Verifica antes de preguntar.
Los verdaderos amigos se hieren con la verdad, para no perderlos con la mentira. - Eugenio Maria de Hostos

Etiquetas: null
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 04:23.