Monday, 26 August 2013

Using xslt, how to add an xml node that starts before the first occurrence, and ends after the last occurrence of an item?

Using xslt, how to add an xml node that starts before the first
occurrence, and ends after the last occurrence of an item?

I have an xml that looks like this:
<ShoppingList>
<MoneyIHaveToSpend>20.00</MoneyIHaveToSpend>
<Item>
<Name>Apples</Name>
<Price>1.00</Price>
</Item>
<Item>
<Name>Oranges</Name>
<Price>1.00</Price>
</Item>
<AdditionalInfo>...</AdditionalInfo>
</ShoppingList>
I would like to wrap the "items" into a GroceryList, like so:
<ShoppingList>
<MoneyIHaveToSpend>20.00</MoneyIHaveToSpend>
<GroceryList>
<Item>
<Name>Apples</Name>
<Price>1.00</Price>
</Item>
<Item>
<Name>Oranges</Name>
<Price>1.00</Price>
</Item>
</GroceryList>
<AdditionalInfo>...</AdditionalInfo>
</ShoppingList>
How would I go about doing that using xslt? There is only one sub-list
inside of "ShoppingList".

No comments:

Post a Comment