I have a Grid and a column in it open up a modal. I want to display XML in that modal which is stored as formatted string. I want it look like like a proper XML and it must collapse tags as well. How to do this ? I'm using Bootstrap 3, mvc5.
Asked
Active
Viewed 1,149 times
1 Answers
0
The most easy way is to iframe the xml data. Most browsers show the xml nicely formatted with collapse tags as well.
With a string you can do that as well like this: https://jsfiddle.net/wypyewvt/
Just add it in the src
of the iframe with src="data:text/xml;charset=utf-8,YOURCONTENT_HERE
.

Niki van Stein
- 10,564
- 3
- 29
- 62
-
But what my code returns to me is a string. Will be able to display that string in the iframe and still get nice XML view ? – Tejas Kanitkar Sep 29 '15 at 07:12
-
Understood. But the output is not something that I want. My output must be XML with collapsible tags and not just mere text. Like this:
142131 ABC XYZ F 12/12/1977 -
I see that it works different in different browsers, and also not very good in jsfiddle for some reason. I will try something different (although sometimes it does work in jsfiddle and sometimes it doesnt.. weird) – Niki van Stein Sep 29 '15 at 07:28
-
Cool. Let me know if you find a way. Meanwhile even I'm trying to find a way as you told. – Tejas Kanitkar Sep 29 '15 at 07:30
-
Did you also check: http://stackoverflow.com/questions/1366179/how-to-display-xml-in-a-html-page-as-a-collapsible-and-expandable-tree-using-jav ? – Niki van Stein Sep 29 '15 at 07:39
-
Check this page: http://www.levmuchnik.net/Content/ProgrammingTips/WEB/XMLDisplay/DisplayXMLFileWithJavascript.html Looks very promising for you. – Niki van Stein Sep 29 '15 at 10:58