Reference files:
<script src="../../Content/dp.SyntaxHighlighter/Scripts/shCore.js" type="text/javascript"></script>
<script src="../../Content/dp.SyntaxHighlighter/Scripts/shBrushXml.js" type="text/javascript"></script>
<link href="../../Content/dp.SyntaxHighlighter/Styles/SyntaxHighlighter.css" rel="stylesheet" type="text/css" />
html Code:
<pre class="brush:xml;">
@Html.Encode("<?xml version='1.0'?><response value='ok' xml:lang='en'> <text>Ok</text> <comment html_allowed='true'/> <ns1:description> descriptin. </ns1:description> <a></a> <a/></response>")
</pre>
JavaScript Code:
<script type="text/javascript">
SyntaxHighlighter.all()
</script
here is got reference tutorial
If you take a look at the source you'll notice that you're excaping the XML two times since @
already encodes the text while @Html.Encode(..)
does it again. Therefore you're not getting correct output that SyntaxHighlighter undestand as code.
Just test using this example and everything will work fine:
<!DOCTYPE html>
<html>
<head>
<link href="http://alexgorbatchev.com/pub/sh/current/styles/shCore.css"
rel="stylesheet" type="text/css" />
<link href="http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css"
rel="stylesheet" type="text/css" />
</head>
<body>
@{
var xml = @"
<?xml version='1.0'?>
<response value='ok' xml:lang='en'>
<text>Ok</text>
<comment html_allowed='true'/>
<ns1:description> descriptin. </ns1:description>
<a></a>
<a/>
</response>";
}
<pre class="brush: xml">
@xml
</pre>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js"
type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shAutoloader.js"
type="text/javascript"></script>
<script type="text/javascript">
SyntaxHighlighter.autoloader(
'xml xhtml xslt html http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js'
);
SyntaxHighlighter.all();
</script>
</body>
</html>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With