Páginas

quinta-feira, 8 de abril de 2010

Lendo arquivo .XML no php.  "Ná marrá!"

Olha só na minha gambiarra!

Arquivo "index.php":

class txttoxml{
var $result;

function arquivo($file){
$fp = fopen($file, "r");
$texto = fread($fp, 1024*1024);
fclose($fp);
$this->result = $texto;
$dom = new domDocument;
$dom->loadXML($this->result);
$xml = simplexml_import_dom($dom);
$merda=0;
while($merda
<count($xml->indo)){
print $xml->indo[$merda++]."
<br/>";
}
}
}

$obj = new txttoxml();
echo $obj->arquivo("xml.xml");

?>



Arquivo "xml.xml":


<dudu>
<indo>Dudu1</indo>
<indo>Dudu2</indo>
<indo>Dudu3</indo>
</dudu>

Falow!

Nenhum comentário: