# Have a beginner question for an xml id3 ace

**URL:** https://forum.kirupa.com/t/have-a-beginner-question-for-an-xml-id3-ace/330625
**Category:** programming
**Created:** [February 19, 2013, 9:20pm UTC](https://forum.kirupa.com/t/have-a-beginner-question-for-an-xml-id3-ace/330625 "2013-02-19T21:20:24Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![FJW](https://avatars.discourse-cdn.com/v4/letter/f/ee59a6/32.png) [@FJW](https://forum.kirupa.com/u/FJW)
#### Post date: [February 19, 2013, 9:20pm UTC](https://forum.kirupa.com/t/have-a-beginner-question-for-an-xml-id3-ace/330625/1 "2013-02-19T21:20:24Z")

</div>

Hi this piece of code works well and passes mp3 and wav data in my website.  
You can see it at [http://futureshapes.net/apps.php](http://futureshapes.net/apps.php) to clarify the situation.  
At present the data is hand written for the file info.

Could anyone give an idea how to put the ID3 data in the XML output below?  
Thanks in advance for any help given.  
Best  
F

\<code\>  
\<?php  
include ‘Zend/Media/Id3v1.php’;  
$myfeed = new RSSFeed();

// Open the current directory (or specify it) and grab only .mp3 and .wav files …  
$dir = opendir (“music”);  
while (false !== ($file = readdir($dir))) {  
if (strpos($file, ‘.mp3’,1)||strpos($file, ‘.wav’,1) ) {  
$myfeed-\>SetItem(“[http://192.168.0.10/music/$file](http://192.168.0.10/music/%24file)”, “$file”, “”);  
}  
}  
// Write the XML File to a file.  
$fp = fopen(‘rss.xml’, ‘w’);  
fwrite($fp, $myfeed-\>output());  
fclose($fp);  
class RSSFeed {  
// VARIABLES  
// channel vars  
var $channel\_url;  
var $channel\_title;  
// items  
var $items = array();  
var $nritems;

// FUNCTIONS  
// constructor  
function RSSFeed() {  
$this-\>nritems=0;  
$this-\>channel\_url=’’;  
$this-\>channel\_title=’’;  
}  
// set channel vars  
function SetChannel($url, $title, $description, $lang, $copyright, $creator, $subject) {  
$this-\>channel\_url=$url;  
$this-\>channel\_title=$title;  
}  
// set item  
function SetItem($url, $title, $description) {  
$this-\>items[$this-\>nritems][‘url’]=$url;  
$this-\>items[$this-\>nritems][‘title’]=$title;  
$this-\>nritems++;  
}

```
// output feed   
function Output() {     
    $output = '&lt;?xml version="1.0" encoding="UTF-8"?&gt;'."

```

“;  
$output = ‘\<XML\>’.”  
";

```
    for($k=0; $k&lt;$this-&gt;nritems; $k++) {  

```

//$id3 = new Zend\_Media\_Id3v1(‘id3v1.tag’);  
$output .= ‘\<Song\>’."  
“;  
$output .= ‘\<songTitle\>’.$this-\>items[$k][‘title’].’\</songTitle\>’.”  
“;  
$output .= ‘\<songArtist\>\</songArtist\>’.”  
“;  
$output .= ‘\<songAlbum\>\</songAlbum\>’.”  
“;  
$output .= ‘\<songTrack\>\</songTrack\>’.”  
“;  
$output .= ‘\<songYear\>\</songYear\>’.”  
“;  
$output .= ‘\<songGenre\>\</songGenre\>’.”  
“;  
$output .= ‘\</Song\>’.”  
";  
}  
$output .= ‘\</XML\>’;  
return $output;  
}  
};  
?\>  
\</code\>
