I have below xml data with duplicate tags for CONS_BILL_NUMBER, one has null value and another has not null value.
XML data:
<G_ITEM>
<PAYMENT_ID>2020</PAYMENT_ID>
<CONS_BILL_NUMBER></CONS_BILL_NUMBER>
<TYPE>TEST</TYPE>
<TRX_DATE>01-JUN-14</TRX_DATE>
<DUE_DATE>01-JUL-14</DUE_DATE>
<CURRENCY_B>USD</CURRENCY_B>
<ORIGINAL_AMOUNT>2800</ORIGINAL_AMOUNT>
<BALANCE_DUE>2800</BALANCE_DUE>
<CONS_BILL_NUMBER>33333</CONS_BILL_NUMBER>
<CD_ORIGINAL_AMOUNT> 2,800.00 </CD_ORIGINAL_AMOUNT>
<CD_BALANCE_DUE> 2,800.00 </CD_BALANCE_DUE>
</G_ITEM>
XSL code:
<xsl:for-each select=".//G_MAIN">
<xsl:for-each select=".//G_ITEM">
<Row ss:AutoFitHeight="0" ss:Height="13.6875">
<Cell ss:StyleID="s20"><Data ss:Type="String"><xsl:value-of select=".//ancestor-or-self::*/COLLECTOR"/></Data></Cell>
<Cell ss:StyleID="s20"><Data ss:Type="String"><xsl:value-of select=".//ancestor-or-self::*/NAME"/></Data></Cell>
<Cell ss:StyleID="s20"><Data ss:Type="String"><xsl:value-of select=".//ancestor-or-self::*/NUMBER_A"/></Data></Cell>
<Cell ss:StyleID="s20"><Data ss:Type="String"><xsl:value-of select=".//ancestor-or-self::*/LOCATION"/></Data></Cell>
<Cell ss:StyleID="s20"><Data ss:Type="String"><xsl:value-of select="CONS_BILL_NUMBER"/></Data></Cell>
<Cell ss:StyleID="s20"><Data ss:Type="String"><xsl:value-of select="TYPE"/></Data></Cell>
<Cell ss:StyleID="s17"><Data ss:Type="String"><xsl:value-of select="TRX_DATE"/></Data></Cell>
<Cell ss:StyleID="s17"><Data ss:Type="String"><xsl:value-of select="DUE_DATE"/></Data></Cell>
<Cell ss:StyleID="s20"><Data ss:Type="String"><xsl:value-of select="CURRENCY_B"/></Data></Cell>
<Cell ss:StyleID="s17"><Data ss:Type="String"><xsl:value-of select="CD_ORIGINAL_AMOUNT"/></Data></Cell>
<Cell ss:StyleID="s17"><Data ss:Type="String"><xsl:value-of select="CD_BALANCE_DUE"/></Data></Cell>
</Row>
</xsl:for-each>
</xsl:for-each>
The xsl code is returning the null value as it is taking the first tag and not the 33333.
Please help to parse this xml to get the second xml tag that has a value in it.
Thanks Vishnu
No comments:
Post a Comment