How to get a part of a string in XSL?

Discussion in 'XML' started by Diandian Zhang, Apr 6, 2005.

  1. Hi, everyone,

    I have a problem in getting a substring.
    In the following XML code, I just want to get the 7 of the "7dt0".
    With "<xsl:variable name="var1" select="A_range/text()"/>", I can get
    "

    7dt0 ".
    How can I continue with the var1 to get 7 from it?

    Thanks a lot!

    <A_range>
    <Size>8</Size>
    <Decimal>255</Decimal>
    <Hex>0xff</Hex>

    7dt0 </A_range>
     
    Diandian Zhang, Apr 6, 2005
    #1
    1. Advertising

  2. Diandian Zhang wrote:

    > I have a problem in getting a substring.
    > In the following XML code, I just want to get the 7 of the "7dt0".
    > With "<xsl:variable name="var1" select="A_range/text()"/>", I can get
    > "
    >
    > 7dt0 ".
    > How can I continue with the var1 to get 7 from it?


    > <A_range>
    > <Size>8</Size>
    > <Decimal>255</Decimal>
    > <Hex>0xff</Hex>
    >
    > 7dt0 </A_range>


    You could use
    substring(normalize-space(/A_range/text()[last()]), 1, 1)
    see the definition of string functions in the XPath 1.0 specification:
    <http://www.w3.org/TR/xpath#section-String-Functions>
    XSLT 1.0 uses XPath 1.0 so all the functions defined in XPath 1.0 are
    available in XSLT 1.0.

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Apr 6, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter Caspers

    Generating multi-part HTML with XSL?

    Peter Caspers, Sep 29, 2003, in forum: XML
    Replies:
    2
    Views:
    479
    Dimitre Novatchev
    Sep 30, 2003
  2. Replies:
    1
    Views:
    3,691
    A. Bolmarcich
    May 27, 2005
  3. unaveen
    Replies:
    1
    Views:
    545
    unaveen
    Mar 18, 2008
  4. Jack
    Replies:
    8
    Views:
    306
  5. Anthony
    Replies:
    0
    Views:
    108
    Anthony
    Jan 13, 2006
Loading...

Share This Page