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

    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:
    <schema name="one"></schema>
    <schema name="two"></schema>
    <schema name="three"></schema>
    <schema name="four"></schema>
    <schema name="five"></schema>

    Here is my result:

    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:

    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 04: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, 09:27 PM
  2. JSTL forEach Query
    By wonderpets in forum JavaServer Pages (JSP) and JSTL
    Replies: 5
    Last Post: 07-14-2008, 07:35 PM
  3. How to use Foreach on an Array
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-17-2008, 12:06 AM
  4. Question regarding foreach loop...
    By theonlywalks in forum New To Java
    Replies: 2
    Last Post: 03-15-2008, 07: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, 07: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