0

I need to display a XML format data fetched from the database to be displayed in a division. But its not displaying with the xml tags on. Is there any way to get xml data as such with the tags in the div?

The xml which i need is given below:

<Name>public</name><Number>848065065639AuthDemoClient:STGKSITM01:20140109052539707</Number><Ret>y</Ret><Tmestamp>2014-01-09T17:22:15.318+05:30GCSD017263</timestamp>

But its getting displayed as follows:

public848065065639AuthDemoClient:STGKSITM01:20140109052539707y2014-01-09T17:22:15.318+05:30GCSD017263

Please suggest a solution

Leeza
  • 127
  • 3
  • 15

2 Answers2

0

In your HTML, you can try displaying it in a textarea like below , it will display XML as it is JsFiddle Example

<div>
<textarea rows="20" cols="40" style="border:none;" disabled>
    <?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>
</textarea>

Abdul Khan
  • 363
  • 3
  • 13
0

Try creating a style like this

<head>
  #xml   { padding-left: 20pt; background-color: #ffffb3; color: #990000; font-size: 14px; font-family: Courier New, Lucida Sans Typewriter, Lucida Typewriter, monospace; font-weight: 600; white-space: pre; }
</head>

Then referencing in the

<textarea id=xml rows="20" cols="40" style="border:none;" disabled>

It's the 'white-space: pre' that's the important bit...

liamj
  • 23
  • 1
  • 5