Hamandeggs1
Hamandeggs1

Reputation: 13

How do I display xml code samples from a razor view?

I'm trying to display code samples to my webpage and the razor view engine is treating the tags as code.

Example:

<?xml version="1.0" encoding="utf-8" standalone="yes"?> does not appear on the page.

How do I stop this functionality?

Upvotes: 1

Views: 686

Answers (1)

SethMW
SethMW

Reputation: 1082

Html.Encode and Html.Raw should do the trick with XML...

   @Html.Encode(Html.Raw("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>"))

ETA: Had that a bit wrong.

Upvotes: 1

Related Questions