Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 25th, 2006, 01:37 PM
Registered User
 
Join Date: Jan 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default JSTL, XML query

I have the following xml document

Code:
<item>
<title>Ali G Interviews The Beckhams</title>
<link>http://www.break.com/articles/aligbeckhams.html</link>
<pubDate>Tue, 24 Jan 2006 21:25:27 CST</pubDate>
<description>Ali G Interviews The Beckhams</description>
<enclosure url="http://media1.break.com/dnet/media/content/aligbeckhams.jpg" type="image/jpeg" length="10000"/>
</item>
and am using the following to parse through it

Code:
<c:import var="xmlfile" url="http://www.break.com/rss/rss20.asp" />
<x:parse var="doc" xml="${xmlfile}"/>
<table border="0" cellspacing="0" cellspacing="0">
<x:forEach select="$doc//item">
<tr><td><strong><a href='<x:out select="link"/>'><x:out select="title"/></a></strong><br>
<em><x:out select="pubDate"/></em><br>
<x:out select="description"/>
<c:out value="${enclosure}"/></td></tr>
</x:forEach>

My only problem is - how do I get the value for the xml tag "enclosure" since it is not in the same format as the others.

I have no control over this xml document as it is an external file - so no suggestions to change it over please :)
Reply With Quote
  #2 (permalink)  
Old January 26th, 2006, 08:11 AM
Registered User
 
Join Date: Jan 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

<x:out select="string(enclosure/@url)"/> - is how I pulled the url value out of the xml file, so my page now looks like this

<c:import var="xmlfile" url="url.link" />
<x:parse var="doc" xml="${xmlfile}"/>
<table border="0" cellspacing="0" cellspacing="0">
<x:forEach select="$doc//item" end="9">
<tr><td><strong><a href='<x:out select="link"/>'><x:out select="title"/></a></strong><br>
<em><x:out select="pubDate"/></em><br>
<a href='<x:out select="link"/>'><img src='<x:out select="string(enclosure/@url)"/>' alt='<x:out select="title"/>' border='0'></a></td></tr>
<tr><td>&nbsp;</td></tr>
</x:forEach>

and it works perfectly
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Issue with displaying result of the query -JSTL shimmeringtrinkets BOOK: Beginning JavaServer Pages 0 June 24th, 2008 08:31 AM
JSTL problem winsonkkp JSP Basics 3 August 9th, 2007 03:20 AM
JSTL XML parsing error pankajbrathi JSP Basics 1 August 29th, 2006 07:35 AM
JSTL aadz5 JSP Basics 1 August 8th, 2005 08:26 AM
JSTL mrkhairy JSP Basics 5 August 8th, 2003 04:57 PM



All times are GMT -4. The time now is 03:59 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.