Web Analytics Made Easy -
StatCounter Help with substring-before - CodingForum

Announcement

Collapse
No announcement yet.

Help with substring-before

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help with substring-before

    I have researched the forums and elsewhere and am now comfortable with using "substring-before". However, I am unable to figure out how to use it in a specific scenario.

    Here is a piece of the XML I'm looking to transform:

    Code:
    <prize  prize_no="6221" prize_name="Big Winner">
    <winning_digits>154-902-342-542-991, Extra: 840</winning_digits>
    </prize>
    Here is a piece of my XSL code:

    Code:
    <WinningNumbers>
    <xsl:attribute name="dt:dt">string</xsl:attribute>
    <xsl:value-of select="winning_digits" />
    </WinningNumbers>
    What I'm trying to do is only parse the following from <winning_digits>: 154-902-342-542-991. Basically, everything before the comma. I can't figure out how to get substring-before to work with the specific selection of "winning_digits".

    Thanks in advance for any help here...

  • #2
    Originally posted by xsl-newb View Post
    I have researched the forums and elsewhere and am now comfortable with using "substring-before". However, I am unable to figure out how to use it in a specific scenario.

    Here is a piece of the XML I'm looking to transform:

    Code:
    <prize  prize_no="6221" prize_name="Big Winner">
    <winning_digits>154-902-342-542-991, Extra: 840</winning_digits>
    </prize>
    Here is a piece of my XSL code:

    Code:
    <WinningNumbers>
    <xsl:attribute name="dt:dt">string</xsl:attribute>
    <xsl:value-of select="winning_digits" />
    </WinningNumbers>
    What I'm trying to do is only parse the following from <winning_digits>: 154-902-342-542-991. Basically, everything before the comma. I can't figure out how to get substring-before to work with the specific selection of "winning_digits".

    Thanks in advance for any help here...
    "to parse" is too generic, maybe if you provide more details about what you want to could help you more.
    Anyway this is what you want?
    Code:
    <xsl:value-of select="substring-before(winning-digits,',')"/>
    best regards

    Comment


    • #3
      That is exactly what I needed! Thanks a lot!

      Comment


      • #4
        Originally posted by xsl-newb View Post
        That is exactly what I needed! Thanks a lot!
        you are welcome,

        probably this will help you:

        http://zvon.org/xxl/XSLTreference/Output/index.html

        best regards

        Comment

        Working...
        X