I'm doing quite a bit of manual XML editing (the source definition of some code generation I'm doing is a custom XML format) and of course prefer to use Emacs over any special purpose (usually ugly) XML editors. nXml mode has stood me well in the past, but I cannot get my head around its "outline" support. Various internet and SO posts effectively say nothing - I'm wondering if anyone has any practical experience with outlining/folding XML in Emacs (any mode) whether or not that requires altering the XML structure itself.
(require 'hideshow) (require 'sgml-mode) (require 'nxml-mode) (add-to-list 'hs-special-modes-alist '(nxml-mode "<!--\\|<[^/>]*[^/]>" "-->\\|</[^/>]*[^/]>" "<!--" sgml-skip-tag-forward nil)) (add-hook 'nxml-mode-hook 'hs-minor-mode) ;; optional key bindings, easier than hs defaults (define-key nxml-mode-map (kbd "C-c h") 'hs-toggle-hiding)
You can use the code from there, slightly modified, for nxml-mode easily.
This will allow you to toggle hiding/unhiding of xml elements with C-ch and will support underscores in the names.
web-mode has element folding built in and bound to C-c C-f. But you will lose some of the features of using nxml-mode obviously.