Displaying XML using google-code-prettify
Asked Answered
G

2

5

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

Glamour answered 30/10, 2014 at 14:59 Comment(1)
What did you end up using to encode the xml?Sunglass
Y
8

The root cause is html tag symbol.

Change < to &lt;

Change > to &gt;

Yelmene answered 17/6, 2016 at 12:38 Comment(0)
S
4

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.

Shelba answered 23/8, 2015 at 23:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.