Get the numeric value inside string in element

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • deepab1983
    New Member
    • Mar 2010
    • 5

    Get the numeric value inside string in element

    Hai,

    My XML Data is as follows:

    Code:
    <TAXDETAIL>
             <EACHTAX>
                <TAXNAME>CST 12.5 % On Equipments</TAXNAME>
                <TAXVALE>1091.25</TAXVALE>
             </EACHTAX>
             <EACHTAX>
                <TAXNAME>CST 2 %</TAXNAME>
                <TAXVALE>174.60</TAXVALE>
             </EACHTAX>
             <EACHTAX>
                <TAXNAME>VAT 12.5%</TAXNAME>
                <TAXVALE>1249.48</TAXVALE>
             </EACHTAX>
          </TAXDETAIL>
    I need to display only the tax rate as 12.5% in the Tax name. I have used
    <xsl:value-of select="substri ng-beforeTAXNAME,' %')"/>
    it outputs the value as CST 12.5.
    Is there any possibility to fetch the numeric value alone from the XML data tag. Please reply me with the code.

    Thanking you
    Last edited by jkmyoung; Jun 7 '10, 12:16 PM.
  • dschu012
    New Member
    • Jul 2008
    • 39

    #2
    Originally posted by deepab1983
    Hai,

    My XML Data is as follows:

    <TAXDETAIL>
    <EACHTAX>
    <TAXNAME>CST 12.5 % On Equipments</TAXNAME>

    <TAXVALE>1091.2 5</TAXVALE>
    </EACHTAX>

    <EACHTAX>
    <TAXNAME>CST 2 %</TAXNAME>

    <TAXVALE>174.60 </TAXVALE>
    </EACHTAX>

    <EACHTAX>
    <TAXNAME>VAT 12.5%</TAXNAME>

    <TAXVALE>1249.4 8</TAXVALE>
    </EACHTAX>
    </TAXDETAIL>

    I need to display only the tax rate as 12.5% in the Tax name. I have used
    <xsl:value-of select="substri ng-beforeTAXNAME,' %')"/>
    it outputs the value as CST 12.5.
    Is there any possibility to fetch the numeric value alone from the XML data tag. Please reply me with the code.

    Thanking you
    Code:
    <xsl:value-of select="substring-before(substring-after(TAXNAME,'CST '),'%')"/>

    Comment

    Working...