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 5 of 5
  1. #1
    Regular Coder Jazzo's Avatar
    Join Date
    Apr 2008
    Location
    New York City
    Posts
    164
    Thanks
    20
    Thanked 2 Times in 2 Posts

    XSL For Each Child Node

    This is my code:
    Code:
    <xsl:for-each select="child::*">
    <td>
    <xsl:value-of select="/"/>
    </td>
    </xsl:for-each>
    I want it to display the value of each child element in a separate tablecell. Instead it combines every child element into one cell. How would you do this?
    ~Julian
    14 y/o web developer, drummer, and Bridge player

  • #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
    Why "child::*" instead of "./*"?

  • #3
    Regular Coder Jazzo's Avatar
    Join Date
    Apr 2008
    Location
    New York City
    Posts
    164
    Thanks
    20
    Thanked 2 Times in 2 Posts
    I don't know but either way it's not working
    ~Julian
    14 y/o web developer, drummer, and Bridge player

  • #4
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Jazzo View Post
    This is my code:
    Code:
    <xsl:for-each select="child::*">
    <td>
    <xsl:value-of select="/"/>
    </td>
    </xsl:for-each>
    I want it to display the value of each child element in a separate tablecell. Instead it combines every child element into one cell. How would you do this?
    Code:
    <xsl:for-each select="child::*">
    <td>
    <xsl:value-of select="/"/>
    </td>
    </xsl:for-each>
    try to use '.' or '*' instead of '/' for select in value-of. Which one to use depend of what is child::*.
    you can debug the xpath using value-of or message.
    Code:
    <!-- if  this don't output something xpath is wrong -->
    <xsl:value-of select="child::*">
    <xsl:for-each select="child::*">
    <td>
    <xsl:value-of select="."/>
    </td>
    </xsl:for-each>
    Edit: look inside the source page to be sure that show something

    best regards
    Last edited by oesxyl; 11-01-2008 at 11:07 PM.

  • Users who have thanked oesxyl for this post:

    Jazzo (11-01-2008)

  • #5
    Regular Coder Jazzo's Avatar
    Join Date
    Apr 2008
    Location
    New York City
    Posts
    164
    Thanks
    20
    Thanked 2 Times in 2 Posts
    Thank you so much
    ~Julian
    14 y/o web developer, drummer, and Bridge player


  •  

    Posting Permissions

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