Ver Mensaje Individual
  #2 (permalink)  
Antiguo 26/07/2009, 23:25
luis008
 
Fecha de Ingreso: abril-2009
Mensajes: 14
Antigüedad: 15 años
Puntos: 0
Respuesta: Me pueden ayudar con php y xml

Al fin me salio. Yo creo que le puede servir a alguien

Archivosphp

prueva.php
Código PHP:
<?php

   
// Carga una cadena XML desde un archivo...  
  
$xmlstr file_get_contents'noticas.xml' );  
  
$library = new SimpleXMLElement$xmlstr );  
    
  
// Carga un archivo XML  
  
$library = new SimpleXMLElement('noticas.xml'nulltrue);  


   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 
'<td>' $book->song '</td>'
      echo 
'</tr>';  
   }  
   echo 
'</table>';  


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

Novede.xml

Código PHP:
 <library>  
     <
book isbn="0345342968">  
        <
title>Fahrenheit 451</title>  
         <
author>RBradbury</author>  
         <
publisher>Del Rey</publisher>  
         
     </
book>  

     <
songs isbn="0345342968">  
        <
title>Fahrenheit 451</title>  
         <
author>RBradbury</author>  
         <
publisher>Del Rey</publisher>  
         <
song>Luis Sagastume</song>
     </
songs