Combine XML elements with xsl

Posted by mpenrow on Stack Overflow See other posts from Stack Overflow or by mpenrow
Published on 2010-05-15T00:04:46Z Indexed on 2010/05/15 0:14 UTC
Read the original article Hit count: 263

Filed under:
|

I have the following xml:

<RowSet>
  <Row>
    <Number>12345</Number>
    <Quantity>42</Quantity>
  </Row>
  <Row>
    <Number>12345</Number>
    <Quantity>12</Quantity>
  </Row>
  <Row>
    <Number>54321</Number>
    <Quantity>37</Quantity>
  </Row>
</RowSet>

I want to use an xsl to combine the elements with the same Number and the resulting should sum the Quantity elements. So the output should look like this:

<RowSet>
  <Row>
    <Number>12345</Number>
    <Quantity>64</Quantity>
  </Row>
  <Row>
    <Number>54321</Number>
    <Quantity>37</Quantity>
  </Row>
</RowSet>

© Stack Overflow or respective owner

Related posts about xslt

Related posts about xsl