Here is how I would do it with XSLT 1.0:
Code:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:key name="by-ProgId" match="ProgramInfo" use="PartnerInformationGrp/ProgId"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="ProgramInfoList">
<xsl:copy>
<xsl:apply-templates select="ProgramInfo[generate-id() = generate-id(key('by-ProgId', PartnerInformationGrp/ProgId)[1])]" mode="group"/>
</xsl:copy>
</xsl:template>
<xsl:template match="ProgramInfo" mode="group">
<xsl:copy>
<xsl:apply-templates select="PartnerInformationGrp | key('by-ProgId', PartnerInformationGrp/ProgId)/AmtInformationGrp"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
With that stylesheet the input
Code:
<response>
<GetTestWSResponse>
<CardNumber>12345</CardNumber>
<ProgramInfoList>
<ProgramInfo>
<PartnerInformationGrp>
<PartnerId>H</PartnerId>
<ProgId>H00002</ProgId>
</PartnerInformationGrp>
<AmtInformationGrp>
<HighAmt>19999.00</HighAmt>
<LowAmt>0.00</LowAmt>
</AmtInformationGrp>
</ProgramInfo>
<ProgramInfo>
<PartnerInformationGrp>
<PartnerId>H</PartnerId>
<ProgId>H00001</ProgId>
</PartnerInformationGrp>
<AmtInformationGrp>
<HighAmt>24.00</HighAmt>
<LowAmt>2.00</LowAmt>
</AmtInformationGrp>
</ProgramInfo>
<ProgramInfo>
<PartnerInformationGrp>
<PartnerId>H</PartnerId>
<ProgId>H00002</ProgId>
</PartnerInformationGrp>
<AmtInformationGrp>
<HighAmt>19.00</HighAmt>
<LowAmt>12.00</LowAmt>
</AmtInformationGrp>
</ProgramInfo>
<ProgramInfo>
<PartnerInformationGrp>
<PartnerId>H</PartnerId>
<ProgId>H00001</ProgId>
</PartnerInformationGrp>
<AmtInformationGrp>
<HighAmt>1744.00</HighAmt>
<LowAmt>99.00</LowAmt>
</AmtInformationGrp>
</ProgramInfo>
</ProgramInfoList>
</GetTestWSResponse>
</response>
is transformed into the result
Code:
<response>
<GetTestWSResponse>
<CardNumber>12345</CardNumber>
<ProgramInfoList>
<ProgramInfo>
<PartnerInformationGrp>
<PartnerId>H</PartnerId>
<ProgId>H00002</ProgId>
</PartnerInformationGrp>
<AmtInformationGrp>
<HighAmt>19999.00</HighAmt>
<LowAmt>0.00</LowAmt>
</AmtInformationGrp>
<AmtInformationGrp>
<HighAmt>19.00</HighAmt>
<LowAmt>12.00</LowAmt>
</AmtInformationGrp>
</ProgramInfo>
<ProgramInfo>
<PartnerInformationGrp>
<PartnerId>H</PartnerId>
<ProgId>H00001</ProgId>
</PartnerInformationGrp>
<AmtInformationGrp>
<HighAmt>24.00</HighAmt>
<LowAmt>2.00</LowAmt>
</AmtInformationGrp>
<AmtInformationGrp>
<HighAmt>1744.00</HighAmt>
<LowAmt>99.00</LowAmt>
</AmtInformationGrp>
</ProgramInfo>
</ProgramInfoList>
</GetTestWSResponse>
</response>