Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts

    I don't understand the interaction of xsl:for-each and xsl:value-of

    Say I've got really simple xml:

    Code:
    <webpage>
        <para>some text in paragraph 1</para>
        <para>some text in paragraph 2</para>
        <para>some text in paragraph 3</para>
    </webpage>
    And what I want to do is:

    Code:
    <xsl:for-each select="webpage/para">
        <p>
            <xsl:value-of select="para" />
        </p>
    </xsl:for-each>
    But of course it doesn't work - there's no <para> inside <para> to get the value of !

    I'm obviously failing to grasp something fundamental ... ??

  • #2
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    Inside the for-each, the para element is now the context node.

    Use:

    <xsl:value-of select="."/>


  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Simple as that ... That clears it up nicely. Thanks


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •