开发者

How to display raw XML string in browser

开发者 https://www.devze.com 2023-04-05 03:52 出处:网络
I have an XML string that I actually want to display on screen. I have tried using Html.Raw(myXMLString) but it displays without the n开发者_开发百科ode names, I have tried outputting without Html.Ra

I have an XML string that I actually want to display on screen.

I have tried using Html.Raw(myXMLString) but it displays without the n开发者_开发百科ode names, I have tried outputting without Html.Raw but same result

How can I display a raw XML string in the browser?


Use

@myXMLString

That should do the trick?

Otherwise, set the HTTP content-type header to text/plain and send raw. I imagine your header currently is text/html hence you need to escape it.


Did you try <code></code> tag?


Is XML the only thing you're trying to display? What about changing the content type?:

Page.Request.ContentType = "text/xml";

If you're only trying to display a section of XML on the page, I would try rendering it into a <pre> tag.

I'm not sure about this one, but you might be able to use a Literal too, with the Mode set to PassThrough.


I ended up using Html.Encode before sending it back

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号