Tips - How to display a XML Tags in a HTML Web Page

ADVERTISEMENT

Displaying a XML document in HTML would not display properly because the browser will apply formatting to XML document and one of the way to tell browser not to apply formatting is to use the ‘<’

For example if you would like to show the following XML code in your html page.

<note>
    <to>Tove</to>
    <from>Jani</from>
    <heading>Reminder</heading>
    <body>Don’t forget me this weekend!</body>
</note>

it will display as shown below

    Tove    Jani    Reminder    Don't forget me this weekend! 

and if you want avoid this behaviour then all you need to do is to replace all < element with ‘&lt;’ (remove single quotes).

Technorati Tags: , ,

Bookmark this post:
  • connotea
  • del.icio.us
  • De.lirio.us
  • digg
  • Furl
  • NewsVine
  • Reddit
  • Spurl
  • YahooMyWeb

Leave a Reply