Solved

Formating and Displaying  XML data, in a JSP?

Posted on 2007-11-22
2
612 Views
Last Modified: 2013-11-24
I am writing a web page wrapper for another website that gives results back from a search of Documents.
I am creating it using JSP & Servlets. I allow the user to enter in a Search word on the webpage and hit submit, this search word gets passed from the JSP to a Servlet. The servlet then adds this query to a url and hits another website to get back info.
It all works fine and the information that is returned is like...Author, Book Name etc.

But it comes back in a StringBuffer. The StringBuffer is just full of text and the text is in XML. I am not sure of what is the best way to seperate out the data so it can be displayed back neatly onto a JSP.
Not sure what the best way to parse this data is?

Can anyone help?
0
Comment
Question by:ShamD
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Accepted Solution

by:
jcoombes earned 90 total points
ID: 20337849
You might want to transform the resultant XML using XSLT which can produce HTML (or whatever you want) which you can then embed/display within your JSP.

There are numerous examples of how to do this kind of stuff on web, here's one site that describes the basic process quite well:

http://www.informit.com/articles/article.aspx?p=26351&seqNum=7&rl=1

Given that you have your XML information in a StringBuffer, then you just need to change the bits that refer to a StreamSource so that you build the source based on the contents of the buffer.
/*
 * e.g.
 */
 
StreamSource src= new StreamSource(stringBuffer.toString());

Open in new window

0
 
LVL 25

Expert Comment

by:Tomas Helgi Johannsson
ID: 20463473
    Hi!

Here is several JSP XML examples to look at :
http://www.java2s.com/Code/Java/JSP/XML.htm
http://www.java2s.com/Code/Java/JSP/JSPXMLandXSLTtransform.htm

Regards,
   Tomas Helgi
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question