到ASP.NET页面上显示XML最简单的方法 [英] Easiest way to display XML on an ASP.NET page

查看:90
本文介绍了到ASP.NET页面上显示XML最简单的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个XmlDocument一些XML,我想以显示它的ASP.NET页面上。 (该XML应该是在控制;该网页将包含其它内容)。现在,我们正在使用的XML的控制。麻烦的是,XML将不显示任何缩进。难看。

I have some XML in an XmlDocument, and I want to display it on an ASP.NET page. (The XML should be in a control; the page will have other content.) Right now, we're using the Xml control for that. Trouble is, the XML displays with no indentation. Ugly.

看来,我应该为它创建一个XSLT,但似乎有点无聊。我宁愿只是把它变成一个控制并让它自动地正确地解析XML和缩进。有没有一种简单的方法来做到这一点?

It appears that I'm supposed to create an XSLT for it, but that seems kind of boring. I'd rather just throw it into a control and have it automagically parse the XML and indent correctly. Is there an easy way to do that?

推荐答案

您可以尝试使用的XmlWriter / XmlTextWriter对象,设置了作家的压痕财产,写一个StringBuilder或MemoryStream的,并输出&LT内部的结果; pre>标签

You could try to use XmlWriter/XmlTextWriter, set the writer's Indentation property, write to a StringBuilder or MemoryStream, and output the result inside a <pre> tag

这篇关于到ASP.NET页面上显示XML最简单的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆