Bonjour,
Je tente de lister les chemins xpath d'un XML

Le XML :
Code XML : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<CONF_2008 xsi:noNamespaceSchemaLocation="Conference.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<OrgLegalName>a</OrgLegalName>
<OrgAcronym>a</OrgAcronym>
....
<HumanResources>
<HRFunction>a</HRFunction>
<HRNberOfStaff>1</HRNberOfStaff>
<HRCost>1</HRCost>
<HRManMonth>1</HRManMonth>
<HRComments>a</HRComments>
</HumanResources>
<E1Staff>1234567891</E1Staff>
<I6OtherCurrentFunding>0</I6OtherCurrentFunding>
</CONF_2008>
 
Cela devrait ressembler à :
 
/conf_2008/OrgLegalName
/conf_2008/OrgAcronym
...
/conf_2008/HumanResources
/conf_2008/HumanResources/HRFunction
/conf_2008/HumanResources/HRNberOfStaff
....
/conf_2008/I6OtherCurrentFunding

Pour le moment je suis à ce niveau (avec une multitude d'essais)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
function parseXML($node,$parent)
{
    if (!$node->read())
        return;
    //If this is a text node then test for attributes.
    if ($node->nodeType==1)
    {
            /*print str_pad('',$node->depth,"_",STR_PAD_LEFT).$node->name.'/('.$parent.')<br>';*/
            print $parent.'<br>';
            $parent .= $node->name.'/';
 
    }
    //Call the recursive method again.
    parseXML($node,$parent);
 
}
$reader = new XMLReader();
$reader->open("test_data.xml");
 
parseXML($reader,"/");
?>
La fonction idéale devait traiter n'importe quel XML et sortir les XPATH pour que l'on puisse les stocker dans une table d'une DB dans le but d'accéder au données stockées dans un XMLType (Oracle).

Merci!!