Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying XML using google-code-prettify

I can't seem to get google prettify to work with basic XML: anyone got this to work, or can see what I am doing wrong: here is my code:

<html>
<head>
<meta charset="utf-8" />

<script src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js?autoload=true&amp;skin=sunburst&amp;lang=xml"></script>

</head>

<body>
<h1>XML Output</h1>

<pre class="prettyprint" id="quine" style="border:4px solid #88c">

<Rest_appt_pull licenseKey="123" passWord="456" start="30-oct-2014 00:00:00" finish="31-oct-2014 23:59:59" p_method="event">
<timings>
<entry label="Read" 
time=".03" 
segment=".03" />
<entry label="Processing XML" 
time=".04" 
segment=".01" />
</timings>
</Rest_appt_pull>

</pre>

</body>
</html>

Any help would be gratefully appreciated

like image 631
Spleenboy Avatar asked Oct 30 '14 14:10

Spleenboy


2 Answers

The root cause is html tag symbol.

Change < to &lt;

Change > to &gt;

like image 173
Andy Cheng Avatar answered Oct 20 '22 16:10

Andy Cheng


You need to html encode your xml code example first. You can use one of available online tools to do that. Then just wrap it in pre/code

<pre class="prettyprint lang-xml"> ... your html encoded xml code ... </pre>

and attach js code on the site.

like image 30
ITmeze Avatar answered Oct 20 '22 16:10

ITmeze