Display xml content in a <div>

View: New views
2 Messages — Rating Filter:   Alert me  

Display xml content in a <div>

by Sudhi Kulkarni :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I have the following sample file and I want to be able to display xml content as xml only... 

<body>
  <div>
  <animal>
  <name>cat</name>
  <legs>4</legs>
  </animal>
  </div>

  </body>

The current output on browsers is cat 4 ... I want the entire xml <animal><name>... displayed..

I guess all the tags are dropped since < is not escaped and <animal> is not a valid tag... 

I need to do this since I cannot escape all < with &lt since the xml is fetched from a dvice..

Thanks,

Sudhi


Re: Display xml content in a <div>

by Phillip Conrad-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear Sudhi:

W3C is a web standards body, and this list is just for discussing those standards, and possible changes to those standards in the future.  So unfortunately we can't help you here.

You may want to  check out a site such as w3schools.com.   A particular topic that may be helpful for what you are trying to do is XSLT---this enables, among other things, transformation of XML content into HTML that your browser can display.

Or you might try asking on a website such as stackoverflow.com.   I hope this is helpful.

Regards,
Phill


P.S. - Thanks to David Calhoun for his example of how to respond to inquires such as this one when they arrive at www-html---my response is adapted from his.   Following his practice, I've CCed to the mailing list for an example of how these emails should be handled, and to let others know that Sudhi has already received a response.

On Thu, Apr 9, 2009 at 8:29 PM, Sudhindra Kulkarni <kulkarni.sudhi@...> wrote:

Hi,

I have the following sample file and I want to be able to display xml content as xml only... 

<body>
  <div>
  <animal>
  <name>cat</name>
  <legs>4</legs>
  </animal>
  </div>

  </body>

The current output on browsers is cat 4 ... I want the entire xml <animal><name>... displayed..

I guess all the tags are dropped since < is not escaped and <animal> is not a valid tag... 

I need to do this since I cannot escape all < with &lt since the xml is fetched from a dvice..

Thanks,

Sudhi




--
Phill Conrad, Lecturer (PSOE)*, Dept. of Computer Science
University of California, Santa Barbara
Joint Appointment: College of Creative Studies (www.ccs.ucsb.edu)
pconrad@..., www.cs.ucsb.edu/~pconrad
-----
*PSOE: a UC teaching faculty appointment, corresponding in rank and job security to a tenure-track assistant professor