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 ?
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".
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).
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).
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With