mmm e gli esempi su php.net che ci stanno a fare?
Codice PHP:
$result = ""; //Qui salverò il testo finale
//Da [url]http://it2.php.net/manual/it/domdocument.loadxml.php[/url]
$doc = new DOMDocument();
$doc->loadXML($tuaStringa);
//Da [url]http://it2.php.net/manual/it/domdocument.getelementsbytagname.php[/url]
$dataset = $doc->getElementsByTagName( "product" );
foreach( $dataset as $row )
{
$xmlcodices = $row->getElementsByTagName( "codice" );
$xmlcodice = $xmlcodices->item(0)->nodeValue;
$xmlfiliales = $row->getElementsByTagName( "filiale" );
$xmlfiliale = $xmlfiliales->item(0)->nodeValue;
$xmlagentes = $row->getElementsByTagName( "agente" );
$xmlagente = $xmlagentes->item(0)->nodeValue;
$xmlprezzos = $row->getElementsByTagName( "prezzo" );
$xmlprezzo = $xmlprezzos->item(0)->nodeValue;
$xmlproformas = $row->getElementsByTagName( "proforma" );
$xmlproforma = $xmlproformas->item(0)->nodeValue;
$result .= $xmlcodice.'|'.$xmlfiliale.'|'.$xmlagente.'|'.$xmlprezzo.'|'.$xmlproforma."\n";
}
echo $result;
io comunque della stringa farei un bel trim e toglierei gli spazi, prima di darla in pasto al DOMDocument, perché sennò può causarti dei problemi nel leggere l'albero