Ver Mensaje Individual
  #1 (permalink)  
Antiguo 21/12/2011, 12:54
eybel
 
Fecha de Ingreso: marzo-2007
Mensajes: 782
Antigüedad: 17 años, 1 mes
Puntos: 16
XML parse con PHP simplexml_load_file();

Tengo este codigo, queria saber si es valido o que pasa. Termine con este codigo:

Código PHP:
<?xml version="1.0" encoding="utf-8" ?>
<news>
    
    
    
    <new>
         <title><![CDATA[<a href="/news.php">   First New   </a>]]></title>
        
        <text> If you've got a brain that understands the
complexities of code and an appreciation for
well-designed user experiences, a career in web
technology could be exactly what you're
programmed for. </text>
        <autor>Don't forget me this weekend!</autor>
    </new> 
    
    <new>
         <title><![CDATA[<a href="/news.php">   Second New   </a>]]></title>
        
        <text> In Full Sail University's online Web Design &
Development bachelor's degree program, you'll get
up to speed on industry-standard software and
programming languages, explore</text>
        <autor>Don't forget me this weekend!</autor>
    </new>
    
    <new>
         <title><![CDATA[<a href="/news.php">   Third New   </a>]]></title>
        
        <text> fundamentals of
design and usability, and produce web and mobile
sites from start to finish. You'll launch a digital
portfolio to help engineer your path to a future in the
industry. </text>
        <autor> Don't forget me this weekend!</autor>
    </new>
    
    


    
</news>
Mi php es simple por ahora, es de practica:

Código PHP:
<?php
$xml 
simplexml_load_file('news.xml');

echo 
$xml->new[1]->title;

  
  
?>
Mis mensajes de errores:
Código PHP:
Warningsimplexml_load_file() [function.simplexml-load-file]: news.xml:20parser error xmlParseEntityRefno name in /Applications/XAMPP/xamppfiles/htdocs/news_text.php on line 2

Warning
simplexml_load_file() [function.simplexml-load-file]: <textIn Full Sail Universitys online Web Design in /Applications/XAMPP/xamppfiles/htdocs/news_text.php on line 2

Warning
simplexml_load_file() [function.simplexml-load-file]: ^ in /Applications/XAMPP/xamppfiles/htdocs/news_text.php on line 2 
Ahora cuando solo dejo una noticia <new> </new> y borro las otras 2, si me funciona.

Código PHP:
<?xml version="1.0" encoding="utf-8" ?>
<news>
    
    
    
    <new>
         <title><![CDATA[<a href="www.thechicmagazine.com/news.php">   First New   </a>]]></title>
        
        <text> If you've got a brain that understands the
complexities of code and an appreciation for
well-designed user experiences, a career in web
technology could be exactly what you're
programmed for. </text>
        <autor>Don't forget me this weekend!</autor>
    </new> 
    



    
</news>