Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display XML Data in DIV

Tags:

html

xml

I want to show XML data in DIV. My xml code is below:

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

I want it to be displayed exactly as it is in a div, with all line spacing and xml tags exactly as they are.

Is this possible?

like image 364
cgvector Avatar asked Dec 27 '22 01:12

cgvector


1 Answers

So I guess your problem is that you are trying to put the XML code into the DIV, and the browser tries to interprete the XML tags as HTML tags? You can prevent that by replacing all "<" and ">" in the XML code with the HTML special chars &gt; and &lt.

like image 144
Philipp Avatar answered Dec 29 '22 14:12

Philipp