Witam,
Mam pewien problem z przechodzenie po drzewie xml, które przedstawiam poniżej,

  1.      <data>
  2.            <unit calendar="1">
  3.                  <component id="1">
  4.                        <history>
  5.                              <tuple>
  6.                                    <value id="2">XXXXXXX</value>
  7.                                    <value id="4">XXXXXXX</value>
  8.                              </tuple>
  9.                        </history>
  10.                  </component>
  11.                  <component id="7">
  12.                        <history>
  13.                              <value id="7"/>
  14.                        </history>
  15.                  </component>
  16.                  <component id="9">
  17.                        <history>
  18.                              <value id="9">XXXXXXX</value>
  19.                        </history>
  20.                  </component>
  21.                  <component id="10">
  22.                        <history>
  23.                              <tuple>
  24.                                    <value id="11">XXXXXXX</value>
  25.                              </tuple>
  26.                        </history>
  27.                  </component>
  28.                  <component id="14">
  29.                        <history>
  30.                              <tuple>
  31.                                    <value id="15">XXXXXXX</value>
  32.                                    <value id="16">XXXXXXX</value>
  33.                                    <value id="17">XXXXXXX</value>
  34.                                    <value id="18">XXXXXXX</value>
  35.                                    <value id="19">XXXXXXX</value>
  36.                              </tuple>
  37.                        </history>
  38.                  </component>
  39.                  <component id="20">
  40.                        <history>
  41.                              <tuple>
  42.                                    <value id="21">XXXXXXX</value>
  43.                                    <value id="22">XXXXXXX</value>
  44.                                    <value id="23">XXXXXXX</value>
  45.                              </tuple>
  46.                        </history>
  47.                  </component>
  48.                  <component id="24">
  49.                        <history>
  50.                              <value id="24">XXXXXXX</value>
  51.                        </history>
  52.                  </component>
  53.                  <component id="25">
  54.                        <history>
  55.                              <value id="25">XXXXXXX</value>
  56.                        </history>
  57.                  </component>
  58.                  <component id="26">
  59.                        <history>
  60.                              <tuple>
  61.                                    <value id="27">XXXXXXX</value>
  62.                                    <value id="28">XXXXXXX</value>
  63.                                    <value id="29">XXXXXXX</value>
  64.                                    <value id="16">XXXXXXX</value>
  65.                                    <value id="30">XXXXXXX</value>
  66.                                    <value id="31">XXXXXXX</value>
  67.                                    <value id="32">XXXXXXX</value>
  68.                                    <value id="34">XXXXXXX</value>
  69.                                    <value id="35">XXXXXXX</value>
  70.                              </tuple>
  71.                        </history>
  72.                  </component>
  73.                  <component id="38">
  74.                        <history>
  75.                              <value id="38">XXXXXXX</value>
  76.                        </history>
  77.                  </component>
  78.                  <component id="43">
  79.                        <history>
  80.                              <tuple begin="2006-04-01">
  81.                                    <value id="44">XXXXXXX</value>
  82.                                    <value id="45">XXXXXXX</value>
  83.                              </tuple>
  84.                        </history>
  85.                  </component>
  86.                  <component id="46">
  87.                        <history>
  88.                              <value id="46">XXXXXXX</value>
  89.                        </history>
  90.                  </component>
  91.                  <component id="47">
  92.                        <history>
  93.                              <value id="47">XXXXXXX</value>
  94.                        </history>
  95.                  </component>
  96.                  <component id="49">
  97.                        <history>
  98.                              <value id="49">XXXXXXX</value>
  99.                        </history>
  100.                  </component>
  101.            </unit>
  102.                 <unit id="XXXX">
  103.               </unit>


Co potrzebuję uzyskać ?
Powyższe drzewo zawiera 'n' obiektów UNIT, a każdy z nich może zawierać do 49 elementów COMPONENT, a każdy z nich jeden lub kilka obiektów VALUE.
Potrzebuję przechodząc przez drzewo jednego obiektu UNIT wyświetlić wszystkie jego obiekty component wraz z wszystkimi obiektami VALUE w jednej lini.
Dobrze by było gdybym mógł ograniczyć się do wyświetlania dla np wszystkich UNIT pewnego zakresu obiektów COMPONENT (np id 7-9) wraz z wszystkimi obiektami VALUE.


Moje wypociny:
  1. <?php
  2. $dane_value = $xml -> xpath('/document/data/unit/component/history/tuple/value');
  3.  
  4. echo "<table>";
  5.  
  6. echo "<tr><td>Value 6</td><td>value 7</td><td>value 8</td><td>value 9</td></tr>";
  7. echo "<tr>";
  8. foreach($dane_value as $val)
  9. {
  10. if(isset($val['id']))
  11. {
  12. echo "<td>" . $val . "</td>";
  13. } else {
  14. echo "<td></td>";
  15. }
  16. }
  17.  
  18. echo "</tr></table>";
  19. ?>


Problem jest jeszcze taki chciałbym aby linie mi się wyświetlały dla każdego UNIT oddzielnie, a otrzymuje jednym ciągiem wszystkie VALUE.
Probowałem ograniczyć linie wyświetlania do ostatniego VALUE w COMPONENCIE, ale nie w każdym UNIT występują COMPONET / VALUE o wszystkich id.

Mam nadzieje, że w miarę przystepny sposób napisałem o co mi chodzi.
Pozdrawiam smile.gif