Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/11/2011, 07:12
Migua01
 
Fecha de Ingreso: noviembre-2007
Mensajes: 7
Antigüedad: 16 años, 5 meses
Puntos: 0
Pregunta Problema con SimpleXMLElement

Buenos días,
Mi problema es el siguiente, he intentado un script básico para leer un xml y me da error. El código es el siguiente:

<?php
// Carga un archivo XML

$library = new SimpleXMLElement('library.xml');
echo '<table>';
echo '<tr>';
echo '<th>Title</th>
<th>Author</th>
<th>Publisher</th>
<th>ISBN</th>';
echo '</tr>';
foreach( $library->book as $book ) {
echo '<tr>';
echo '<td>' . $book->title . '</td>';
echo '<td>' . $book->author . '</td>';
echo '<td>' . $book->publisher . '</td>';
echo '<td>' . $book['isbn'] . '</td>';
echo '</tr>';
}
echo '</table>';

?>



El error es:
PHP Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in H:\webspace\hostings\muevetuweb.es\hosting\www\tes t.php:4 Stack trace: #0 H:\webspace\hostings\muevetuweb.es\hosting\www\tes t.php(4): SimpleXMLElement->__construct('library.xml') #1 {main} thrown in H:\webspace\hostings\muevetuweb.es\hosting\www\tes t.php on line 4


Después he probado a copiar un ejemplo que viene en la pgina de php.net y el error es el mismo.

El problema es con SimpleXMLElement.

Me podria ayudar alguien por favor? me estoy volviendo loca!!