Restructuting XML Data

Posted by Frank on Stack Overflow See other posts from Stack Overflow or by Frank
Published on 2010-06-10T14:58:14Z Indexed on 2010/06/10 15:02 UTC
Read the original article Hit count: 329

Filed under:
|

Hi!

The following is an excerpt of my XML data source:

<file>
<ALL_INSTANCES>
<instance>
<ID>1</ID>
<start>5.8633333333</start>
<end>29.8216666667</end>
<code>Player 1</code>
</instance>
<instance>
<ID>2</ID>
<start>28.4566666667</start>
<end>51.1450000000</end>
<code>Player 2</code>
</instance>
<instance>
<ID>3</ID>
<start>49.8383333333</start>
<end>71.1150000000</end>
<code>Player 3</code>
</instance>
<instance>
<ID>4</ID>
<start>72.9850000000</start>
<end>95.3766666667</end>
<code>Speler 1</code>
</instance>
</ALL_INSTANCES>

I'm looking to restructure this data into something like this:

<Player 1>
    <ID>1</ID>
    <start>5.8633333333</start>
    <end>29.8216666667</end>
</Player 1>
<Player 1>
    <ID>4</ID>
    <start>72.9850000000</start>
    <end>95.3766666667</end>
</Player 1>
<Player 2>
    <ID>2</ID>
    <start>28.4566666667</start>
    <end>51.1450000000</end>
</Player 2>
<Player 3>
    <ID>3</ID>
    <start>49.8383333333</start>
    <end>71.1150000000</end>
</Player 3>

Could anyone please help me to achieve this? Much appreciated!

Cheers, Frank

© Stack Overflow or respective owner

Related posts about Xml

Related posts about xsl