我怎么能写原始XML在ASP.NET一个标签 [英] How can I write raw XML to a Label in ASP.NET

查看:88
本文介绍了我怎么能写原始XML在ASP.NET一个标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到的XML块从Web服务了。客户希望看到这种原始的XML页面上的标签。当我尝试这样的:

I am getting a block of XML back from a web service. The client wants to see this raw XML in a label on the page. When I try this:

lblXmlReturned.Text = returnedXml;

只有文字获取显示,没有任何XML标签。我需要包括会从Web服务返回的一切。

only the text gets displayed, without any of the XML tags. I need to include everything that gets returned from the web service.

这是返回的XML的下调示例:

This is a trimmed down sample of the XML being returned:

<Result Matches="1">
    <VehicleData>
        <Make>Volkswagen</Make>
        <UK_History>false</UK_History>
    </VehicleData>
    <ABI>
        <ABI_Code></ABI_Code>
        <Advisory_Insurance_Group></Advisory_Insurance_Group>
    </ABI>
    <Risk_Indicators>       
        <Change_In_Colour>false</Change_In_Colour>
    </Risk_Indicators>
    <Valuation>
        <Value xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"></Value>
    </Valuation>
    <NCAP>
        <Pre_2009></Pre_2009>
    </NCAP>
</Result>

我能做些什么,使这个出现在屏幕上?我注意到,堆栈溢出确实把XML的scren的pretty好工作。我检查了来源和它的使用&LT; pre&GT; 标记。这是不是我必须要使用?

What can I do to make this appear on the screen? I noticed that Stack Overflow does a pretty good job of putting the XML on the scren. I checked the source and it's using <pre> tags. Is this something that I have have to use?

推荐答案

这将是更容易使用&LT; ASP:文字/&GT; 与它的<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.literal.mode.aspx\"><$c$c>Mode设置为恩code 比对付手动编码标签的文本

It would be easier to use a <asp:Literal /> with it's Mode set to Encode than to deal with manually encoding Label's Text

<asp:Literal runat="server" ID="Literal1"  Mode="Encode" />

这篇关于我怎么能写原始XML在ASP.NET一个标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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