0

when i give request to REST i will get a JSON response but in my partial view i have to show it as XML file

I have used the following . And when i debug it i can get the proper XML file but when it goes to partial view the XML tags are not visible

var Response1 = JsonConvert.DeserializeXmlNode(**"JSON RESPONSE HERE"**, "root").OuterXml.
                ToString().Replace("<?xml version=\"1.0\" encoding=\"utf-8\"?>",string.Empty);

XmlDocument doc1 = new XmlDocument();
doc1.LoadXml(Response1 );

using (StringWriter buffer1 = new StringWriter())
{
    XmlWriterSettings settings1 = new XmlWriterSettings();
    settings1.Indent = true;

    using (XmlWriter writer1 = XmlWriter.Create(buffer1, settings1))
    {
        doc1.WriteTo(writer1);

        writer1.Flush();
    }

    buffer1.Flush();

    var ResponseXML = buffer1.ToString().Replace("<?xml version=\"1.0\" encoding=\"utf-8\"?>", string.Empty);

    @ViewBag.XML = ResponseXML;

    return PartialView();
}

and my partial view is like this

 <p class="heading"><u>XML VIEW OF RESPONSE </u></p>
    <textarea id="feedtext" style="border: none;" readonly>
    @ViewBag.XML
    </textarea>

Can anyone help me

Dan Homola
  • 3,819
  • 1
  • 28
  • 43
backtrack
  • 7,996
  • 5
  • 52
  • 99

1 Answers1

0

The code will be parssed and because of that you loose the Xml Tags, you have to encode it, for more see this question :

how to display XML?

Community
  • 1
  • 1
Swift
  • 1,861
  • 14
  • 17