|
next
|
Subject: empty child nodes Author: Bernard Quinn Date: 14 Aug 2008 02:43 PM
|
I'm confused then (not unusual), because it is for missing elements that I am getting these empty tags. E.G. - say I have three tables, one for boxes, one for colors, one for sizes. Format of all three is the same, an integer, followed by a text field. Each element in boxes can have 0 to many corresponding elements in the color and size tables, all joined together by the primary key of the boxes table (which shows up as a foreign key in the other two tables). Let's say that there are three entries in boxes {(1,"dish"),(2,"clothes"),(3,"book")}. Let's say that the color table has {(1,"red"),(1,"green")} and size has {(1,"small"),(1,"med"),(2,"small")}. Using some left joins from boxes the following info is available:
dish - red - small
dish - red - med
dish - green - small
dish - green - med
clothes - NULL - small
NULL comes from the missing corresponding entry rather than an actual table entry of (2,NULL).
The xml I would like to generate is:
<boxes>
<box>
<name>dish</name>
<color>red</color>
<color>green</color>
<size>small</size>
<size>med</size>
</box>
<box>
<name>clothes</name>
<size>small</size>
</box>
Instead, I end up with an empty node under the clothes box:
<box>
<name>clothes</name>
<color />
<size>small</size>
</box>
|
|
|
|