1

I have my XML as a string and need to display it in a div I have searched all the ways to format an XML, but it doesn't work as I am finally binding my contents to a div.

Following is what I am using in my asp.net applicaion c# code.

request = //my xml string     
XDocument doc = XDocument.Parse(request);
divLogResults.InnerText = doc.ToString()

I have tried all the ways listed here as well

What is the simplest way to get indented XML with line breaks from XmlDocument?

So this isn't a duplicate. How can I do this in a simple way ?

Community
  • 1
  • 1
wickjon
  • 900
  • 5
  • 14
  • 40

1 Answers1

0

Bind your XML content in a text area. I think this should work.

Web form:

   <textarea rows="20" cols="40" style="border:none;" runat="server" id="txtXML" readonly="true">
    </textarea>

Code behind:

request = // xml string     
XDocument doc = XDocument.Parse(request);
txtXML.Text = doc.ToString()

Please make sure your xml content has the header appended e.g.,

<?xml version="1.0" encoding="ISO-8859-1"?>
Ashiq A N
  • 776
  • 1
  • 8
  • 16