0

Hello,

I have a simple xml file online, all I want to do is read 2 things, the song name and song artist.
I searched for a simple php script that does that with no luck.

I really appreciate the help.

This is what the xml file looks like

<stwcue version="1">
<mount>RADIO_ONE</mount>
<cuepoint type="track" cache="true">
<attributes>
<attribute name="cue_title">Bed - (Dubstep 01).mp3</attribute>
<attribute name="track_artist_name">CLINTY</attribute>
<attribute name="track_album_name"/>
<attribute name="cue_time_duration"/>
</attributes>
</cuepoint><
/stwcue>
2
Contributors
2
Replies
4
Views
5 Years
Discussion Span
Last Post by UFO Disko
0

Here is an example on how to read an XML file.
books.xml

<books>
  <book>
  <author>Jack Herrington</author>
  <title>PHP Hacks</title>
  <publisher>O'Reilly</publisher>
  </book>
  <book>
  <author>Jack Herrington</author>
  <title>Podcasting Hacks</title>
  <publisher>O'Reilly</publisher>
  </book>
</books>

readbooks.php

<?php
$doc = new DOMDocument();
$doc->load( 'books.xml' );

$books = $doc->getElementsByTagName( "book" );
foreach( $books as $book ) {
    $authors = $book->getElementsByTagName( "author" );
    $author = $authors->item(0)->nodeValue;

    $publishers = $book->getElementsByTagName( "publisher" );
    $publisher = $publishers->item(0)->nodeValue;

    $titles = $book->getElementsByTagName( "title" );
    $title = $titles->item(0)->nodeValue;

    echo "$title - $author - $publisher\n";
}
?>
0

How can I adapt it to my own xml file because mine is kinda different and I have already tried that example with no luck.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.