
08/10/2004, 14:35
|
| | Fecha de Ingreso: enero-2002
Mensajes: 29
Antigüedad: 23 años Puntos: 0 | |
Proba con esto:
<?php
$xml = "ruta a tu archivo xml";
function mostrar_categoria($categoria) {
foreach ($categoria as $propiedad => $value) {
$variable = $propiedad;
$$variable = $value;
}
echo '<p><a href="' . $link . '"><strong>' . $id . '</strong></a> - ' . $qty . '</em>';
}
$categorias = array();
$i = 0;
function opening_element($parser, $elemento, $atributos) {
global $categorias;
global $i;
if ($elemento == 'category') {
foreach ($atributos as $atributo => $valor) {
$categorias[$i][$atributo] = $valor;
}
$i++;
}
}
function closing_element($parser, $element) {
}
$parser = xml_parser_create();
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false);
xml_set_element_handler($parser, 'opening_element', 'closing_element');
if (!$document = @file($xml)) {
exit();
}
foreach ($document as $line) {
xml_parse($parser, $line);
}
while ( list($id_categoria, $categoria) = each($categorias) ) {
mostrar_categoria($categoria);
}
xml_parser_free($parser);
?> |