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>

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";
}
?>

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.