Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display XML content in HTML page

Tags:

html

jquery

xml

How to display XML and other type of data in same page ?

    <?xml version="1.0" encoding="ISO-8859-1"?> <catalog>     <cd>         <title>Empire Burlesque</title>         <artist>Bob Dylan</artist>         <country>USA</country>         <country>Columbia</country>         <price>10.90</price>         <year>1985</year>     </cd> </catalog> 

The above XML should be displayed as it is with formatting. Also , I would like to display HTML tables and other stuff in my page. How to achieve this ?

  1. I do get XML in STRING not through file.
  2. I do not want to parse it
  3. I want to display (that's it)
  4. If you say about XSLT ( please give example )
  5. I'm thinking to use Jquery plugin ( any examples?)
like image 530
karthi Avatar asked Sep 22 '11 18:09

karthi


People also ask

How do I display XML content in HTML?

To view raw XML source, try to select "View Page Source" or "View Source" from the browser menu. Note: In Safari 5 (and earlier), only the element text will be displayed. To view the raw XML, you must right click the page and select "View Source".

Can you embed XML in HTML?

With Internet Explorer 5.0, XML can be embedded within HTML pages in Data Islands. The unofficial <xml> tag is used to embed XML data within HTML. Note that the <xml> tag is an HTML element, not an XML element. Data Islands can be bound to HTML elements (like HTML tables).

How a XML document can be displayed on a browser?

You can add a stylesheet association processing instruction to an XML document that specifies a stylesheet for a web browser to use when displaying it. To display an XML document in a web browser: 1. You must first decide whether or not your XML document needs to reference a document type declaration (DTD).


1 Answers

Simple solution is to embed inside of a <textarea> element, which will preserve both the formatting and the angle brackets. I have also removed the border with style="border:none;" which makes the textarea invisible.

Here is a sample: http://jsfiddle.net/y9fqf/1/

like image 199
mellamokb Avatar answered Sep 22 '22 22:09

mellamokb