H
hilz
Hi all
I have this situation where I have an xml file similar to this:
<Root>
<MyElement year="2004"><Amount>10</Amount></MyElement>
<MyElement year="2004"><Amount>11</Amount></MyElement>
<MyElement year="2005"><Amount>15</Amount></MyElement>
<MyElement year="2006"><Amount>4</Amount></MyElement>
<MyElement year="2006"><Amount>7</Amount></MyElement>
<MyElement year="2004"><Amount>20</Amount></MyElement>
...
...
</Root>
Now I want to summarize this by transforming it into something like this
<Root>
<MyElement year="2004">
<Amounnt>10</Amount>
<Amounnt>11</Amount>
<Amounnt>20</Amount>
</MyElement>
<MyElement year="2005">
<Amounnt>15</Amount>
</MyElement>
<MyElement year="2006">
<Amounnt>4</Amount>
<Amounnt>7</Amount>
</MyElement>
</Root>
The problem I am having is how to loop through the MyElement elements
and get all amounts for a given unique year, then go to the next year.
In other words, I want to be able to use the year as a unique key for my
iterations.
Any help is greatly appreciated.
Thanks
I have this situation where I have an xml file similar to this:
<Root>
<MyElement year="2004"><Amount>10</Amount></MyElement>
<MyElement year="2004"><Amount>11</Amount></MyElement>
<MyElement year="2005"><Amount>15</Amount></MyElement>
<MyElement year="2006"><Amount>4</Amount></MyElement>
<MyElement year="2006"><Amount>7</Amount></MyElement>
<MyElement year="2004"><Amount>20</Amount></MyElement>
...
...
</Root>
Now I want to summarize this by transforming it into something like this
<Root>
<MyElement year="2004">
<Amounnt>10</Amount>
<Amounnt>11</Amount>
<Amounnt>20</Amount>
</MyElement>
<MyElement year="2005">
<Amounnt>15</Amount>
</MyElement>
<MyElement year="2006">
<Amounnt>4</Amount>
<Amounnt>7</Amount>
</MyElement>
</Root>
The problem I am having is how to loop through the MyElement elements
and get all amounts for a given unique year, then go to the next year.
In other words, I want to be able to use the year as a unique key for my
iterations.
Any help is greatly appreciated.
Thanks