Ver Mensaje Individual
  #2 (permalink)  
Antiguo 02/01/2008, 11:45
Avatar de bulter
bulter
 
Fecha de Ingreso: enero-2008
Mensajes: 137
Antigüedad: 16 años, 4 meses
Puntos: 20
Re: recorrer xml con simpleXml

Código PHP:
<?php

class setEdit{
    public 
$xmlId;
    
    public function 
SetEditores($stringXml){
        
$xmlsimplexml_load_string($stringXml);
        
        foreach (
$xml->tituloBibliograficas[0] as $ED){
            
$this->xmlId[] = $ED->id;
            
        }
    }  
    
    public function 
getId(){
        
        return 
$this->xmlId;
    }
}
    
$string = <<<XML
            <xml>
                <tituloBibliograficas>
                    <editor>    
                        <id>1</id>
                    </editor>
                    <editor>
                        <id>2</id>
                    </editor>
                    <editor>
                        <id>3</id>
                    </editor>
                </tituloBibliograficas>
            </xml>

XML;

$xmlClass = new setEdit();
$xmlClass->SetEditores($string);
$id $xmlClass->getId();

foreach(
$id as $ids){
    echo 
"Id: ".$ids."<br />";
}
?>