• Post Reply Bookmark Topic Watch Topic
  • New Topic

parsing data... formatting xml in the JSP?  RSS feed

 
Geoff Garcia
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure if this is a JSP question, or a java/class file question? or xml or what, so forgive me if its in the wrong section.

Basically I'm integrating with a web service that returns some form of XML.

This is a snippet of my code from my JSP, this particular snippet is in client side javaScript.
numGuess is my java/class file and getHint processes my request to get the info by running the URL.

document.Search.searchText.value = "<%= numguess.getHint()%>"
alert(document.Search.searchText.value);



When I run this command an alert box pops up that contains the following test:
<xmlRouterResponse><queryAndResponseSet> <queryAndResponse>
<query>gsk</query>
<response>GSK</response>
<response>Glaxo SmithKline</response>
<response>GlaxoSmithKline</response>
</queryAndResponse></queryAndResponseSet></xmlRouterResponse>


which as you can see still contains the <> xml tags.
Is there a way I can yank out just the appropriate response data and query data?
I would like my result set to come back (for this example)
to include (space delimited): gsk GSK Glaxo SmithKline GlaxoSmithKline

Can this be done at the class/java file level? or should I persue doing this at the javascript level or in the server side JSP?
[ August 03, 2004: Message edited by: Geoff Garcia ]
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSTL contains a full set of XML handling and XSLT processing tags.
 
Geoff Garcia
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I should have mentioned that I'm a complete j2ee noob.
On a scale of 1-10 (10 being expert) I'm about a 1.
So! I've never heard of JSTL, is that something additional I'd have to install?
I'm working on google doing searches trying to find out more about it, but everything dealing with JSTL seems to involve uber complex (to me) things, and nothing basic about what it is, how to install it, or how to use it.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSTL is the JSP Standard Tag Library.

If you are just starting out, the best thing you can do for yourself is to grab a book on JSP 2.0 (make sure it's fairly recent and covers 2.0), and dive in.
 
Geoff Garcia
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Am already looking on google and in books.
Am not looking to learn the in's and out's of java at this time, just how to fix this tiny issue. I have to get it done by friday.
So if anyone has any specific help on how to do it (rather than generic) that would be appreciated.
Thanks
[ August 04, 2004: Message edited by: Geoff Garcia ]
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Geoff,

If you get stuck you could adapt the code below for use in your NumGuess class. It does basically what you want.


Not exactly elegant, but perhaps useful.

Rgds

Jules
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!