0

Dear All!

I am facing a small issue in showing xml in a proper format. I am getting proper xml data from my webservice. but after receiving it browser is treating it as a text and showing all test in single line. I want to show my xml data same as we open xml file in browser. How can i do this.

Here is my code

 $("#getXml").click(function () {
               var xmlhttp;
               xmlhttp = new XMLHttpRequest();
               xmlhttp.onreadystatechange = function () {
                   if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {

                       $("#divResult").html(xmlhttp.response);

                   }
               }
               //        alert("email.aspx?all=""&id="3"&item=""&type="");
               xmlhttp.open("GET", "e.aspx?all=&id='3'&item=&type=", true);
               xmlhttp.send();
           });

Regards

Edited by pritaeas: Moved to Javascript

2
Contributors
2
Replies
12
Views
3 Years
Discussion Span
Last Post by minitauros
1

I guess that the problem is that you are trying to display XML as XML in an HTML document.

It works like this: Your HTML document has already told your browser it's an HTML document. Therefore your browser will treat your document as an HTML document. If you want the XML to be displayed as how a plain XML file would be displayed if you'd open it with your browser, you need to create a whole new browser window and tell that window that it is an XML - not an HTML - file it should display, and then output the XML.

As M.Qawas Aslam says, using an iframe might do the trick. If that doesn't work, I suggest you open a whole new tab or browser window to display the XML. Or, alternatively, you could search for options to display XML as XML without opening a new window.

Votes + Comments
Thanks for explanation :)
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.