Results 1 to 1 of 1
  1. #1
    GrahamButcher is offline Member
    Join Date
    Oct 2010
    Posts
    3
    Rep Power
    0

    Default x:forEach problem

    NOTE: I have had to put a space after x: because this forum gives me smileys if I don't.

    What am I doing wrong?

    Here is the relevant bit of my code:
    <x: parse var="doc" xml="${xml}" />
    <x: forEach select="$doc/document/schema">
    <x: out select="@name" />
    </x: forEach>

    Here is the relevant bits of my xml doc:
    <document>
    <schema name="one"></schema>
    <schema name="two"></schema>
    <schema name="three"></schema>
    <schema name="four"></schema>
    <schema name="five"></schema>
    </document>

    Here is my result:
    two

    I want to list them all not just the second one.

    I have done an x: out on $doc and it gives me everything.

    I have done an x: out on $doc/document/schema and it gives me everything in the second schema.

    I have tried:
    $doc//document//schema
    $doc//schema
    $doc//schema/*

    If I do this:
    <x: forEach select="$doc/document/*">
    <x: out select="@name" />
    </x: forEach>

    I get the name attributes for non schema elements as well.

    I'm a complete noob to jstl, xpath, and jsp, so don't get too technical with me.
    Last edited by GrahamButcher; 10-22-2010 at 03:45 PM.

Similar Threads

  1. <c:forEach to list data in X columns
    By polygrimm in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 12-04-2009, 08:27 PM
  2. JSTL forEach Query
    By wonderpets in forum JavaServer Pages (JSP) and JSTL
    Replies: 5
    Last Post: 07-14-2008, 06:35 PM
  3. How to use Foreach on an Array
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-16-2008, 11:06 PM
  4. Question regarding foreach loop...
    By theonlywalks in forum New To Java
    Replies: 2
    Last Post: 03-15-2008, 06:15 AM
  5. foreach in jstl to display nested colums-struts jsp
    By adil7 in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 02-11-2008, 06:19 AM

Tags for this Thread

Posting Permissions

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