I think I can do that for your example:
(If you download this into a scratch.html file, and view the result in your browser, you'll see better what I'm doing here.)<html><body> <table border=1 cellspacing=0 cellpadding=3> <caption>Items</caption> <tr><td rowspan=6>Item1</td><td colspan=2>foo:</td><td>a</td></tr> <tr><td colspan=2>bar:</td><td>b</td></tr> <tr><td colspan=2>baz:</td><td>c</td></tr> <tr><td rowspan=3>Item2</td><td>foo:</td><td>d</td></tr> <tr><td>bar:</td><td>e</td></tr> <tr><td>baz:</td><td>f</td></tr> <tr><td rowspan=3>Item3</td> <td colspan=2>foo: </td><td>x</td></tr> <tr><td colspan=2>bar:</td><td>y</td></tr> <tr><td colspan=2>baz:</td><td>z</td></tr> </body></html>
Some tricks here - you've got to traverse the whole tree before you start generating the table – you've got to know what the maximum depth is. You make the table that many columns wide. And you have to know how many leaf elements there are within each item, so you know how many rows tall to make its block.
I've previously generated HTML tables to represent structures nested 10 levels deep, with on the order of 200 elements.
The nesting is a bit of a problem, but one I've solved previously.
In reply to Re^4: Going between XML and Cgi by way of DTD
by throop
in thread Going between XML and CGi by way of DTD
by throop
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |