![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
05/09/2014, 10:47
|
| | Fecha de Ingreso: marzo-2007
Mensajes: 31
Antigüedad: 17 años, 11 meses Puntos: 0 | |
Respuesta: Leer y crear tabla con resultados de XML Aqui esta tu solucion:
Tu XML tendria que estar asi:
<?xml version="1.0"?>
<data>
<item title="ProductoA" xml_load="750" prc="salida"></item>
<item title="CargaA" xml_load="850" prc="entada"></item>
<item title="ProductoC" xml_load="Agente" prc="espera"></item>
<item title="Celular" xml_load="Nokia" prc="23456788"></item>
<item title="Direccion" xml_load="Calle" prc="8765432"></item>
</data>
Y tu codigo Php seria:
<?php
$xml = 'ejemplo.xml';
$usuarios = simplexml_load_file($xml);
echo'
<h1>Resultados</h1>
<table width="100%" border="00" cellspacing="0" cellpadding="0">
';
foreach($usuarios->item as $item){
$titulo = $item['title'];
$xml_load = $item[xml_load];
$prc = $item[prc];
echo'
<tr>
<td>'.$titulo.'</td>
<td>'.$xml_load.'</td>
<td>'.$prc.'</td>
</tr>
';
}
echo'
</table>
';
?>
y el Resultado es:
Resultados
ProductoA 750 salida
CargaA 850 entada
ProductoC Agente espera
Celular Nokia 23456788
Direccion Calle 8765432
Espero te sirva, puedes modificarlo a lo que necesitas.
Saludos |