Tengo que crear un XML apartir de una consulta de MySQL ya se hace pero necesito que quede exactamente con este formato:
[xml]
<chart>
<chart_type>pie</chart_type>
<chart_data>
<row>
<null/>
<string>2007</string>
<string>2008</string>
<string>2009</string>
</row>
<row>
<string>Region A</string>
<number>10</number>
<number>30</number>
<number>63</number>
</row>
</chart_data>
</chart>
[/xml]
Basicamente asi es como estoy tratando de crearlo
Código PHP:
   <?php
 
header("Content-type: text/xml");
 
$host = "Localhost"; 
$user = "test"; 
$pass = "xxx"; 
$database = "test";
 
$enlace = mysql_connect($host, $user, $pass) or die("Error MySQL."); 
mysql_select_db($database, $enlace) or die("Error base de datos.");
 
$query = "SELECT AGENTE, count(*) FROM clientes group by agente"; 
$resultado = mysql_query($query, $enlace) or die("Sin resultados.");
 
$salida_xml = "<?xml version=\"1.0\"?>\n"; 
 
$salida_xml .= "<chart>\n";
$salida_xml .= "<chart_type>" . 'pie' . "</chart_type>\n";
    $salida_xml .= "<chart_data>\n";
    for($x = 0 ; $x < mysql_num_rows($resultado) ; $x++){
 
        $fila = mysql_fetch_assoc($resultado); 
        $salida_xml .= "\t<row>\n"; 
        $salida_xml .= "\t\t<agente>" . $fila['AGENTE'] . "</agente>\n"; 
        $salida_xml .= "\t\t<cantidad>" . $fila['count(*)'] . "</cantidad>\n"; 
            // Corregiendo caracteres incorrectos
            $fila['texto'] = str_replace("&", "&", $fila['texto']); 
            $fila['texto'] = str_replace("<", "<", $fila['texto']); 
            $fila['texto'] = str_replace(">", ">", $fila['texto']); 
           // $salida_xml .= "\t\t<texto>" . $fila['texto'] . "</texto>\n"; 
        $salida_xml .= "\t</row>\n"; 
    }//segundo for
    $salida_xml .= "</chart_data>\n";
 
 
$salida_xml .= "</chart>";
 
echo $salida_xml;
 
?>    [xml]
This XML file does not appear to have any style information associated with it. The document tree is shown below.
−
<chart>
<chart_type>pie</chart_type>
−
<chart_data>
<row>
</row>
−
<row>
<agente>Danilo</agente>
<cantidad>8</cantidad>
</row>
<row>
</row>
−
<row>
<agente>Evelyn</agente>
<cantidad>5</cantidad>
</row>
<row>
</row>
−
<row>
<agente>Maribel</agente>
<cantidad>2</cantidad>
</row>
<row>
</row>
−
<row>
<agente>Nestor</agente>
<cantidad>11</cantidad>
</row>
<row>
</row>
−
<row>
<agente>Noemy</agente>
<cantidad>2</cantidad>
</row>
</chart_data>
</chart>
[/xml]
LA verdad es mi primera ves utilizando xml y no tengo ni la menor idea de como hacer que quede parecido ya que necesito que se "dibuje" una tabla con esta forma
Cantidad
Danilo 8
Evelyn 10
Marco 4
Alguien que me ayude por favoooooooooooooooooooooooor
 

