Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display XML source code using HTML with Emacs?

In the HTML file, I need to show some XML code. The problem is that I can't use

<pre>..</pre> 

to show '<' and '>'.

What would be the solution for this problem?

ADDED

From the answer, replacing '<' and '>' to &lt; and&gt; can be a solution. I'm an Emacs user, are there Emacs tools/magic to do that automatically? I mean, I can use search and replace, but I expect Emacs can do it by 'select region' -> 'M-x replace_xml' or something.

like image 473
prosseek Avatar asked Feb 27 '23 06:02

prosseek


2 Answers

You need to escape < as &lt; and & as &amp;. Optionally, for consistency, you can escape > as &gt;

To do this automatically in Emacs, if you're in HTML mode, you can select the code that you would like to escape, and run M-x sgml-quote.

like image 190
Brian Campbell Avatar answered Mar 07 '23 00:03

Brian Campbell


You need to replace < by &lt; and > by &gt;. How to do this depends on the server side language in question.


Update: as per your update: this is not programming related anymore. I think http://superuser.com is a better place to ask software related questions.

like image 40
BalusC Avatar answered Mar 07 '23 00:03

BalusC