Hello all...

Someone asked a question about this in the Flash forum and it stirred my curiosity, so I am trying to build a system to create an XML file via data pulled from MySQL.

After some googling, I came across this:

PHP Code:
<?php

// Simon Willison, 16th April 2003
// Based on Lars Marius Garshol's Python XMLMaker class
// See http://www.xml.com/pub/a/2003/04/09/py-xml.html

class XMLMaker {
    var 
$xml;
    var 
$indent;
    var 
$stack = array();
    function 
XMLMaker($indent '  ') {
        
$this->indent $indent;
        
$this->xml '<?xml version="1.0" encoding="utf-8"?>'."\n";
    }
    function 
_indent() {
        for (
$i 0$j count($this->stack); $i $j$i++) {
            
$this->xml .= $this->indent;
        }
    }
    function 
push($element$attributes = array()) {
        
$this->_indent();
        
$this->xml .= '<'.$element;
        foreach (
$attributes as $key => $value) {
            
$this->xml .= ' '.$key.'="'.htmlentities($value).'"';
        }
        
$this->xml .= ">\n";
        
$this->stack[] = $element;
    }
    function 
element($element$content$attributes = array()) {
        
$this->_indent();
        
$this->xml .= '<'.$element;
        foreach (
$attributes as $key => $value) {
            
$this->xml .= ' '.$key.'="'.htmlentities($value).'"';
        }
        
$this->xml .= '>'.htmlentities($content).'</'.$element.'>'."\n";
    }
    function 
emptyelement($element$attributes = array()) {
        
$this->_indent();
        
$this->xml .= '<'.$element;
        foreach (
$attributes as $key => $value) {
            
$this->xml .= ' '.$key.'="'.htmlentities($value).'"';
        }
        
$this->xml .= " />\n";
    }
    function 
pop() {
        
$element array_pop($this->stack);
        
$this->_indent();
        
$this->xml .= "</$element>\n";
    }
    function 
getXml() {
        return 
$this->xml;
    }
}



$xml = new XMLMaker();
$array = array(
    array(
'title''creator''image''location'),
    array(
'title''creator''image''location'),
    array(
'title''creator''image''location'),
);

$xml->push('playlist');
foreach (
$array as $song) {
    
$xml->push('title', array('species' => $song[0]));
    
$xml->element('creator'$song[1]);
    
$xml->element('image'$song[2]);
    
$xml->element('location'$song[3]);
    
$xml->pop();
}
$xml->pop();

print 
$xml->getXml();


?>
This creates an XML file to the specs that I need.

My next step is to figure out how to save this data as an XML file so it can be read by a Flash mp3 player.

Does anyone know how to go about doing this?

The second issue is how to link it to a MySQL database and get those arrays the way that I need. Any help with that is also appreciated.

Thanks!