Good! I'm trying to traverse the data of an xml document, for the time being, but when I have to deal with the attributes of some tags, it's when I get lost.
$agenda = new SimpleXMLElement("prueba.xml", 0, true);
foreach($agenda->personas->persona as $persona) {
echo $persona->nombre . "<br>";
echo $persona->apellidos . "<br>";
echo $persona->fechanac . "<br>";
echo $persona->ciudad . "<br>";
foreach($persona->contacto["tipo"] as $contacto) {
switch($contacto){
case "email":
echo "<b>Email: " . $contacto . "<br>";
break;
case "tlf":
echo "<b>Teléfono: " . $contacto . "<br>";
break;
}
}
echo "<br>";
}
This shows all the data correctly but passes olympically on the labels that have the type attribute