Ver Mensaje Individual
  #13 (permalink)  
Antiguo 13/04/2011, 07:23
Section1
 
Fecha de Ingreso: diciembre-2003
Mensajes: 173
Antigüedad: 20 años, 4 meses
Puntos: 1
Respuesta: Como leer un xml en php y mostrarlo

Hola de Nuevo,

He visto que en php no puedo hacer que cada minuto consulte el documento xml...

Asi que necesitaria saber como hacer la lectura del documento en javascript...?

He desarrollado este codigo pero no me funciona.

Código Javascript:
Ver original
  1. function cargarXML()
  2. {
  3. var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
  4. xmlDoc.async = false;
  5. xmlDoc.load("http://www.radiocarmelo.eu/temas.xml");
  6.  
  7. document.write("<html>");
  8. document.write("<body >");
  9. $song = xmlDoc.getElementsByTagName("Event")[0].("Song")[0].firstChild.nodeValue
  10. }
  11. document.write("</body>");
  12. document.write("</html>");


Y este es el xml

- <Schedule System="Jazler">
- <Event status="happening" startTime="12:47:29" eventType="song">
<Announcement Display="Estas escuchandor:" />
- <Song title="Comadre">
<Album title="20 aros de Carlotas" />
- <Artist name="Las Carlotas">
<Media runTime="216.958" />
<Expire Time="12:51:05" />
<TrackID AUID="11243" />
</Artist>
</Song>
</Event>
</Schedule>



Y este el codigo bueno en php:

Código PHP:
Ver original
  1. <?php
  2. $xml = new SimpleXMLElement('http://www.radiocarmelo.eu/temas.xml', null, true);
  3. $song = $xml->Event->Song['title'];
  4. $album = $xml->Event->Song->Album['title'];
  5. $artist = $xml->Event->Song->Artist['name'];
  6. $status = $xml->Event->Announcement['Display'];
  7.  
  8. $temaonline = "ARTISTA: ".$artist." - TEMA: ".$song." - ALBUM: ".$album."";
  9. ?>
__________________
Deja el mundo mejor que como lo encontraste... By B.P.