当我向REST发出请求时,我将获得JSON响应,但在我的部分视图中,我必须将其显示为 XML文件
我使用了以下内容。当我调试它时,我可以获得正确的XML文件,但是当它进入部分视图时,XML标签不可见
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();
}
我的部分观点是这样的
<p class="heading"><u>XML VIEW OF RESPONSE </u></p>
<textarea id="feedtext" style="border: none;" readonly>
@ViewBag.XML
</textarea>
任何人都可以帮助我