hymerman
Member
Posted 2 years ago #
I just want to post the contents of an XML file I wrote, but WordPress is expectedly interpreting it as HTML and is just displaying the contents of the elements without the elements themselves. Can I tell WordPress to escape the XML somehow, or is there a HTML element that will do this for me?
Thanks!
You need to encode the opening < and closing > characters in your sample markup. So:
<label for="s">Keyword(s)</label> <input class="text" type="text" value="" name="s" id="s" />
would become:
& lt;label for="s"& gt;Keyword(s)& lt;/label& gt; & lt;input class="text" type="text" value="" name="s" id="s" /& gt;
(but remove the space between & and l)
hymerman
Member
Posted 2 years ago #
Thanks, I didn't realise that!
Since it was going to be a bit tedious I did some googling and found an online tool that will replace characters with HTML entities for you:
http://www.opinionatedgeek.com/DotNet/Tools/HTMLEncode/Encode.aspx
Or, you could just wrap in within <code>... </code> tags.
That won't work. <code></code> is simply markup. It won't encode any tags inside.
hymerman
Member
Posted 2 years ago #
Yeah, code tags were the first thing I tried. That would work as long as there weren't any < or > (or some others) symbols in the code, but since it's XML they're quite prevalent :)
Ah, sorry... I misread the codex page.