当我向 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>
谁能帮我