Click to See Complete Forum and Search --> : How to display 'RAW' XML in HTML page


icargill
07-07-2009, 06:51 AM
I have some xml data that I need to display in a HTML page, and I can't get it to quite work how I want it. E.g. If I have an XML file and open it in a browser, it will display as 'pretty-printed' XML. I have an exiting page that I need to load the xml into for display.

I can run the xml through a routine to make it HTML safe (ie. convert <> etc to entities), then load it into the innerHTMl of a div, but there is no decent formatting.

I could labouriously write a parser to do it, but surely there must be some straightforward way of achieving this?? I've tried a few ways (e.g. loading into an IFrame), but still no luck.

I would appreciate any pointers.

webknitter
07-08-2009, 01:42 AM
You can try following links to get your XML issues sorted out:
http://sitemaps.org/
http://code.google.com/p/sitemap-generators/wiki/SitemapGenerators
http://www.xml.com/

ehime
07-16-2009, 10:14 AM
why don't you just use the <pre></pre> html tags?
will display everything WYSIWYG for you. you'll have
to abandon colors (unless you want to write some
tricks), but it should serve everything how you want
it.