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
精彩评论