Emacs nXML: Editing XML with Emacs

Problem

I want to edit XML files with Emacs. There seem to be alternatives. Which one is recommended?

Solution

The package nXML for Emacs provides very solid support for XML and especially comprehensive validation while you edit. The nXML mode uses so called RELAX NG is a schema language for XML, see http://www.relaxng.org/. The nXML seems to be robust and usable and it can cope with fairly large files conveniently (say 10,000 lines) while substantially bigger ones slow the processing down. See http://www.thaiopensource.com/nxml-mode/ for more information on nXML.

The nXML package comes with the Emacs 3.1 and is therefore readily usable. In order to make it the default mode for your XML files, you could add the following lines in your ~/.emacs init file:

;; nXML support:
(setq auto-mode-alist
      (cons '("\\.\\(xml\\|xsl\\|rng\\|xhtml\\)\\'" . nxml-mode)
       auto-mode-alist))

Otherwise, you can try nXML mode by executing the command M-x nxml-mode in a buffer.

-- KimmoKoskenniemi - 26 Feb 2010

Topic revision: r2 - 2010-02-26 - KimmoKoskenniemi
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback