Bonjour à tous,
Je cherche à lister toutes les occurences dans un xml
- Code : Tout sélectionner
<?xml version="1.0" encoding="ISO-8859-1"?> <root> <success>1</success> <result> <result> <mac>70:EE:50:06:47:54</mac> <last_rx> <bitrate>540</bitrate> <mcs>-1</mcs> <shortgi>0</shortgi> <vht_mcs>-1</vht_mcs> <width>20</width> </last_rx> <tx_bytes>14650000</tx_bytes> <last_tx> <bitrate>540</bitrate> <mcs>-1</mcs> <shortgi>0</shortgi> <vht_mcs>-1</vht_mcs> <width>20</width> </last_tx> <id>F4:CA:E5:F8:1A:28-70:EE:50:06:47:54</id> <bssid>F4:CA:E5:F8:1A:28</bssid> <flags> <vht>0</vht> <legacy>0</legacy> <authorized>1</authorized> <ht>0</ht> </flags> <tx_rate>12</tx_rate> <host> <l2ident> <id>70:EE:50:06:47:54</id> <type>mac_address</type> </l2ident> <active>1</active> <id>ether-70:ee:50:06:47:54</id> <last_time_reachable>1491474956</last_time_reachable> <persistent>1</persistent> <vendor_name>Netatmo</vendor_name> <host_type>networking_device</host_type> <l3connectivities> <result> <addr>192.168.0.11</addr> <active>1</active> <reachable>1</reachable> <last_activity>1491474956</last_activity> <af>ipv4</af> <last_time_reachable>1491474956</last_time_reachable> </result> </l3connectivities> <reachable>1</reachable> <last_activity>1491474956</last_activity> <primary_name_manual>1</primary_name_manual> <primary_name>Thermostat</primary_name> </host> <inactive>2</inactive> <conn_duration>953110</conn_duration> <hostname>Thermostat</hostname> <state>authenticated</state> <rx_bytes>14460000</rx_bytes> <rx_rate>12</rx_rate> <signal>-50</signal> </result> <result> <mac>20:D3:90:E7:87:20</mac> <last_rx> <bitrate>120</bitrate> <mcs>-1</mcs> <shortgi>0</shortgi> <vht_mcs>-1</vht_mcs> <width>20</width> </last_rx> <tx_bytes>90390000</tx_bytes> <last_tx> <bitrate>722</bitrate> <mcs>7</mcs> <shortgi>1</shortgi> <vht_mcs>-1</vht_mcs> <width>20</width> </last_tx> <id>F4:CA:E5:F8:1A:28-20:D3:90:E7:87:20</id> <bssid>F4:CA:E5:F8:1A:28</bssid> <flags> <vht>0</vht> <legacy>0</legacy> <authorized>1</authorized> <ht>1</ht> </flags> <tx_rate>0</tx_rate> <host> <l2ident> <id>20:D3:90:E7:87:20</id> <type>mac_address</type> </l2ident> <active>1</active> <id>ether-20:d3:90:e7:87:20</id> <last_time_reachable>1491474945</last_time_reachable> <persistent>1</persistent> <names> <result> <name>android-3f8c04fee27c50be</name> <source>dhcp</source> </result> <result> <name>Android-2</name> <source>mdns</source> </result> <result> <name>BubbleUPnP Media Server (SM-T520)</name> <source>upnp</source> </result> </names> <vendor_name>Samsung Electronics Co.,Ltd</vendor_name> <host_type>tablet</host_type> <l3connectivities> <result> <addr>192.168.0.14</addr> <active>1</active> <reachable>1</reachable> <last_activity>1491474945</last_activity> <af>ipv4</af> <last_time_reachable>1491474945</last_time_reachable> </result> <result> <addr>192.168.0.9</addr> <active>0</active> <reachable>0</reachable> <last_activity>1488139406</last_activity> <af>ipv4</af> <last_time_reachable>1488139406</last_time_reachable> </result> <result> <addr>fe80::22d3:90ff:fee7:8720</addr> <active>1</active> <reachable>1</reachable> <last_activity>1491474921</last_activity> <af>ipv6</af> <last_time_reachable>1491474916</last_time_reachable> </result> </l3connectivities> <reachable>1</reachable> <last_activity>1491474945</last_activity> <primary_name_manual>1</primary_name_manual> <primary_name>Tablette Samsung 10</primary_name> </host> <inactive>1</inactive> <conn_duration>102915</conn_duration> <hostname>Tablette Samsung 10</hostname> <state>authenticated</state> <rx_bytes>13510000</rx_bytes> <rx_rate>0</rx_rate> <signal>-58</signal> </result> </result> </root>
Je veux que le xpath me retourne toutes les valeurs du champs <mac> trouvé. Si je comprends bien la documentation eedomus je devrais tout simplement pouvoir faire //mac Or cela me retourne uniquement la 1ère occurence. Il y a donc quelque chose que je n'ai pas compris ou fais mal.
Une idée ? Merci
|