title: PHP script to echo VLC now playing XML attributes
body: <p>I've been searching for a while on this and haven't had much luck.  I've found plenty of resources showing how to echo data from dynamic XML, but I'm a PHP novice, and nothing I've written seems to grab and print exactly what I want, though from everything I've heard, it should be relatively easy.  The source XML (located at 192.168.0.15:8080/requests/status.xml) is as follows:</p>
  
  <pre><code>&lt;root&gt;
    &lt;fullscreen&gt;0&lt;/fullscreen&gt;
    &lt;volume&gt;97&lt;/volume&gt;
    &lt;repeat&gt;false&lt;/repeat&gt;
    &lt;version&gt;2.0.5 Twoflower&lt;/version&gt;
    &lt;random&gt;true&lt;/random&gt;
    &lt;audiodelay&gt;0&lt;/audiodelay&gt;
    &lt;apiversion&gt;3&lt;/apiversion&gt;
    &lt;videoeffects&gt;
    &lt;hue&gt;0&lt;/hue&gt;
    &lt;saturation&gt;1&lt;/saturation&gt;
    &lt;contrast&gt;1&lt;/contrast&gt;
    &lt;brightness&gt;1&lt;/brightness&gt;
    &lt;gamma&gt;1&lt;/gamma&gt;
    &lt;/videoeffects&gt;
    &lt;state&gt;playing&lt;/state&gt;
    &lt;loop&gt;true&lt;/loop&gt;
    &lt;time&gt;37&lt;/time&gt;
    &lt;position&gt;0.22050105035305&lt;/position&gt;
    &lt;rate&gt;1&lt;/rate&gt;
    &lt;length&gt;168&lt;/length&gt;
    &lt;subtitledelay&gt;0&lt;/subtitledelay&gt;
    &lt;equalizer/&gt;
    &lt;information&gt;
    &lt;category name="meta"&gt;
    &lt;info name="description"&gt;
    000003EC 00000253 00000D98 000007C0 00009C57 00004E37 000068EB 00003DC5 00015F90 00011187
    &lt;/info&gt;
    &lt;info name="date"&gt;2003&lt;/info&gt;
    &lt;info name="artwork_url"&gt; file://brentonshp04/music%24/Music/Hackett%2C%20Steve/Guitar%20Noir%20%26%20There%20Are%20Many%20Sides%20to%20the%20Night%20Disc%202/Folder.jpg
    &lt;/info&gt;
    &lt;info name="artist"&gt;Steve Hackett&lt;/info&gt;
    &lt;info name="publisher"&gt;Recall&lt;/info&gt;
    &lt;info name="album"&gt;Guitar Noir &amp;amp; There Are Many Sides to the Night Disc 2
    &lt;/info&gt;
    &lt;info name="track_number"&gt;5&lt;/info&gt;
    &lt;info name="title"&gt;Beja Flor [Live]&lt;/info&gt;
    &lt;info name="genre"&gt;Rock&lt;/info&gt;
    &lt;info name="filename"&gt;Beja Flor [Live]&lt;/info&gt;
    &lt;/category&gt;
    &lt;category name="Stream 0"&gt;
    &lt;info name="Bitrate"&gt;128 kb/s&lt;/info&gt;
    &lt;info name="Type"&gt;Audio&lt;/info&gt;
    &lt;info name="Channels"&gt;Stereo&lt;/info&gt;
    &lt;info name="Sample rate"&gt;44100 Hz&lt;/info&gt;
    &lt;info name="Codec"&gt;MPEG Audio layer 1/2/3 (mpga)&lt;/info&gt;
    &lt;/category&gt;
    &lt;/information&gt;
    &lt;stats&gt;
    &lt;lostabuffers&gt;0&lt;/lostabuffers&gt;
    &lt;readpackets&gt;568&lt;/readpackets&gt;
    &lt;lostpictures&gt;0&lt;/lostpictures&gt;
    &lt;demuxreadbytes&gt;580544&lt;/demuxreadbytes&gt;
    &lt;demuxbitrate&gt;0.015997290611267&lt;/demuxbitrate&gt;
    &lt;playedabuffers&gt;0&lt;/playedabuffers&gt;
    &lt;demuxcorrupted&gt;0&lt;/demuxcorrupted&gt;
    &lt;sendbitrate&gt;0&lt;/sendbitrate&gt;
    &lt;sentbytes&gt;0&lt;/sentbytes&gt;
    &lt;displayedpictures&gt;0&lt;/displayedpictures&gt;
    &lt;demuxreadpackets&gt;0&lt;/demuxreadpackets&gt;
    &lt;sentpackets&gt;0&lt;/sentpackets&gt;
    &lt;inputbitrate&gt;0.016695899888873&lt;/inputbitrate&gt;
    &lt;demuxdiscontinuity&gt;0&lt;/demuxdiscontinuity&gt;
    &lt;averagedemuxbitrate&gt;0&lt;/averagedemuxbitrate&gt;
    &lt;decodedvideo&gt;0&lt;/decodedvideo&gt;
    &lt;averageinputbitrate&gt;0&lt;/averageinputbitrate&gt;
    &lt;readbytes&gt;581844&lt;/readbytes&gt;
    &lt;decodedaudio&gt;0&lt;/decodedaudio&gt;
    &lt;/stats&gt;
    &lt;/root&gt; 
  </code></pre>
  
  <p>What I'm trying to write is a simple PHP script that echoes the artist's name (In this example Steve Hackett).  Actually I'd like it to echo the artist, song and album, but I'm confident that if I'm shown how to retrieve one, I can figure out the rest on my own.</p>
  
  <p>What little of my script which actually seems to work goes as follows. I've tried more than what's below, but I left out the bits that I know for a fact aren't working.</p>
  
  <pre><code>&lt;?PHP
  $file = file_get_contents('http://192.168.0.15:8080/requests/status.xml');
  $sxe = new SimpleXMLElement($file);
  
  foreach($sxe-&gt;...
  
  echo "Artist: "...
  
  ?&gt;
  </code></pre>
  
  <p>I think I need to use <code>foreach</code> and <code>echo</code>, but I can't figure out how to do it in a way that will print what's <em>between</em> those info brackets.</p>
  
  <p>I'm sorry if I've left anything out. I'm not only new to PHP, but I'm new to StackOverflow too.  I've referenced this site in other projects, and it's always been incredibly helpful, so thanks in advance for your patience and help!</p>
  
  <p>////////Finished Working Script - Thanks to Stefano and all who helped!</p>
  
  <pre><code>&lt;?PHP
  $file = file_get_contents('http://192.168.0.15:8080/requests/status.xml');
  $sxe = new SimpleXMLElement($file);
  
  $artist_xpath = $sxe-&gt;xpath('//info[@name="artist"]');
  $album_xpath = $sxe-&gt;xpath('//info[@name="album"]');
  $title_xpath = $sxe-&gt;xpath('//info[@name="title"]');
  
  
  $artist = (string) $artist_xpath[0];
  $album = (string) $album_xpath[0];
  $title = (string) $title_xpath[0];
  
  
  echo "&lt;B&gt;Artist: &lt;/B&gt;".$artist."&lt;/br&gt;";
  echo "&lt;B&gt;Title: &lt;/B&gt;".$title."&lt;/br&gt;";
  echo "&lt;B&gt;Album: &lt;/B&gt;".$album."&lt;/br&gt;";
  ?&gt;
  </code></pre>