EdB*_*EdB 0 asp.net-mvc asp.net-mvc-3 asp.net-mvc-2
正如John Saunders所建议的那样,我一直在尝试使用XElement.但是我的XML没有在Razor View中缩进.我一定是在做傻事,但我看不到.
控制器代码:
XElement myXElement = XElement.Load(strMapPath + strFileName);
ViewBag.MyOrigDocXML = myXElement;
return View();
Run Code Online (Sandbox Code Playgroud)
Razor Code in View:
@if(ViewBag.MyOrigDocXML != null)
{
@ViewBag.MyOrigDocXML.ToString();
}
Run Code Online (Sandbox Code Playgroud)
任何帮助非常感谢,
我会将你的代码嵌套在pre html标签中
<link href="~/Content/Prettify/prettify.css" rel="stylesheet" />
<script src="~/Scripts/Prettify/prettify.js"></script>
<body onload="prettyPrint()">
<pre class="prettyprint lang-xml">@ViewBag.MyOrigDocXML;</pre>
</body>
Run Code Online (Sandbox Code Playgroud)
这将以缩进的布局为您提供xml,然后添加美化以突出显示xml文本
| 归档时间: |
|
| 查看次数: |
890 次 |
| 最近记录: |