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 | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
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 04:21 PM.


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