Salve, ho uno script trovato in giro che mi permette di creare un file csv partendo da un file xml (rss),
il problema è che nel file xml ci sono nomi come g:id, il campo con il due punti, non riesce ad importarlo.

Il file xml si presenta come cosi:

codice:
<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0">
<channel>
<title><![CDATA[nome]]></title>
<description><![CDATA[descrizione]]></description>
<link>http://www.link.it</link>
<item>
<g:id>codice</g:id>
<title><![CDATA[descrizione prod]]></title>
<link>link prodotto</link>
<g:price></g:price>
ecc....
</channel>
</rss>

Questa è la funzione:


Codice PHP:
function xml2csv($xmlFile$xPath) {

    
// Load the XML file
    
$xml simplexml_load_file($xmlFile);

    
// Jump to the specified xpath
    
$path $xml->xpath($xPath);

    
// Loop through the specified xpath
    
foreach($path as $item) {

        
// Loop through the elements in this xpath
        
foreach($item as $key => $value) {

                        
//$value = str_replace(array("\r", "\n"), " ", $value);
            
$csvData .= trim($value) . '|';

        }

        
// Trim off the extra comma

        
$csvData trim($csvData'|');

        
// Add an LF
        
$csvData .= "\n";

    }

    
// Return the CSV data
    
return $csvData;



Grazie