Changing flat XML into nested
I'm working on a tree navigation that needs to have some data provided in a nested xml format
<node label="California">
<node label="location 1" />
<node label="location 2">
<node label="option 1" />
<node label="option 2" />
</node>
</node>
But the data that I'm getting (and probably can't change) is coming out flat:
<item>
<id>12</id>
<label>California</label>
</item>
<item>
<id>15</id>
<label>location 1</label>
<parent>12</parent>
</item>
<item>
<id>17</id>
<label>location 2</label>
<parent>12</parent>
</item>
<item>
<id>33</id>
<label>option 1</label>
<parent>17</parent>
</item>
<item>
<id>70</id>
<label>loption 2</label>
<parent>17</parent>
</item>
Any suggestions on how to change that data from what I'm supplied to what I need? Is it just a brute force looping through the xml nodes a bunch of times? Or is there a clever way that I'm not seeing?
