title: Populate an HTML table with XML data
body: <p>I would like to populate a table with data from an XML file and was thinking along the lines of:</p>
  
  <p>1.) Create the XML data:    </p>
  
  <pre><code>&lt;menu&gt;
    &lt;pizza&gt;
      &lt;regular&gt;
        &lt;item name="Tomato Cheese"&gt;Tomato Cheese
          &lt;price size="small"&gt;1&lt;/price&gt;
          &lt;price size="large"&gt;2&lt;/price&gt;
          &lt;description&gt;A&lt;/description&gt;
        &lt;/item&gt;
        &lt;item name="Onion"&gt;Onion
          &lt;price size="small"&gt;3&lt;/price&gt;
          &lt;price size="large"&gt;4&lt;/price&gt;
          &lt;description&gt;B&lt;/description&gt;
        &lt;/item&gt;
      &lt;/regular&gt;
    &lt;/pizza&gt;
  &lt;/menu&gt;
  </code></pre>
  
  <p>2.) Create the table in HTML:  </p>
  
  <pre><code>&lt;table border="1"&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th rowspan="2"&gt;Item &lt;/th&gt;
        &lt;th rowspan="2"&gt;Description&lt;/th&gt;
        &lt;th colspan="2"&gt;Price&lt;/th&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;th&gt;Small&lt;/th&gt;
        &lt;th&gt;Large&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      ...
  </code></pre>
  
  <p>3.) Use a foreach statement on an XPath query:          </p>
  
  <pre><code> foreach  ($xml-&gt;xpath('/menu/pizza/descendant::item') as $item)
          {
              print "&lt;tr&gt;&lt;td&gt;".$item."&lt;/td&gt;" ;
          } 
  </code></pre>
  
  <p>This works great for the first row, but I can't figure out how to populate the rest of the columns.</p>