Solved

xml on browser with its tags

Posted on 2004-11-08
228 Views
Last Modified: 2013-11-19
i have table in db which stores the data in xml format
shown below for particular user id..

<tag1>
      <tag2>data1</tag2>
      <tag3>data2</tag3>            
</tag1>

and i am trying to display whole xml segment including its tag
for each user id on browser with "JSP". but browser only displays data
not the whole xml segment for each individual user id..
so output should be like this

<tag1>
      <tag2>data1</tag2>
      <tag3>data2</tag3>            
</tag1>

can we do that without using xslt???
0
Question by:ghatlodia
    3 Comments
     
    LVL 35

    Accepted Solution

    by:
    you need to replace the "<" with "&lt;" and the ">" with "&gt;"

    Then the browser will render it ok :-)

    try:

    <%= xml.replaceAll( "<", "&lt;" ).replaceAll( ">", "&gt;" ) %>

    that may work (but it probably need some escape chars in it ;-) )
    0
     
    LVL 35

    Expert Comment

    by:TimYates
    just tested it...works fine :-)
    0
     
    LVL 1

    Author Comment

    by:ghatlodia
    thanks  TimYates   now it is working fine..
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Prepare to Pass the CompTIA A+ 900 Series Exam

    CompTIA aims to adapt its A+ Certification to reflect the most current knowledge and skills needed by today's IT professionals--and this year's 2016 exam is harder than ever. This certification is one of the most highly-respected and sought after in IT.

    There are two main kinds of selectors in CSS: One is base selector like h1, h2, body, table or any existing HTML tags.  For instance, the following rule sets all paragraphs (<p> elements) to red: (CODE) CSS also allows us to define our own custom …
    Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
    The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

    934 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

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now