malheuresement php 4
voila la fonction qui parse (désolé mais ça veut pas me garder l'indetation [ça existe comme terme?])
<?php
function xml2array($val,&$place)
{
for($compteur=0;$place<count($val);$i)
{
$v = $val[$place++];
switch($v['type']){
case "complete":
$tab[$v['tag']][$compteur]['value']="";
if(!empty($v['value'])) $tab[$v['tag']][$compteur]['value'] = $v['value'];
$tab[$v['tag']][$compteur++]['attributes']="";
if(!empty($v['attributes'])) $tab[$v['tag']][$compteur++]['attributes'] = $v['attributes'];
break;
case "open":
$tab[$v['tag']][$compteur]['value'] = xml2array($val,$place);
$tab[$v['tag']][$compteur++]['attributes']="";
if(!empty($v['attributes'])) $tab[$v['tag']][$compteur++]['attributes'] = $v['attributes'];
break;
case "close":
return $tab;
}
}
return $tab;
}
$xml = file_get_contents("category.xml");
$xp = xml_parser_create();
xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, false);
xml_parser_set_option($xp, XML_OPTION_SKIP_WHITE, true);
xml_parse_into_struct($xp,$xml,$vals,$index);
xml_parser_free($xp);
$i=0;
$tab = xml2array($vals,$i);
?>
Ok.
ça donne quoi ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part var_dump($tab['result'][0]['value']['point'][0]['value']['cat_id'][0]['value']);
ça me donneputain je viens de me rendre compte de ma betise
Code : Sélectionner tout - Visualiser dans une fenêtre à part string(1) "3"
j'essayais d'afficher
merci beaucoup
Code : Sélectionner tout - Visualiser dans une fenêtre à part echo $tab[0]['result']['value']['point'][0]['value']['cat_id'][0]['value'];
Partager