• Post Reply Bookmark Topic Watch Topic
  • New Topic

Display XML in JSP. Catch is to display each tag with different colors

 
Dilip H Pashupathi
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am developing a product where the client needs to display the content of XML in a JSP page. This XML will be extracted from database and will be temporarily sotred in a String object and will then be flushed to JSP page for display. This was working fine unitl now. But now the customer wants display each tag with one color. attribute in another color and data in another color.

For ex:
this should be displayed in one color.
Then

In the above one the tag should be displayed in one color and "Data" should be displayed in another color


In the above sample tag should be in one color and attribute should be in one color ex: red and value of the attribute should be in another color ex: blue and "Data" should be in one color ex: green.

Is this possible to be done and if so can any one point me in the right direction.


The same way code ranch is displaying the content by using [code] tags.

Here is the sample screen shot of how xml should is currently being displayed




Thanks and Regards
Dilip H Pashupathi
sample.png
[Thumbnail for sample.png]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because you are delivering the XML to the page as a string blob, you'll have a hard time using CSS to apply color styles.

What I'd perhaps do is to deliver the HTML as a DOM or other hierarchical construct and use JSTL/EL to create HTML elements that display the values as XML markup, putting hooks (elements and perhaps classes) in the HTML to allow CSS to style the elements accordingly.

You may also be able to leverage the "x" tag library of the JSTL to emit the markup, but I have only limited experience doing that and it was a long time ago,
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!