Folding tags in emacs nxml-mode Folding tags in emacs nxml-mode xml xml

Folding tags in emacs nxml-mode


Its called outlining in nxml-mode, its in section 5 of the nxml-mode documentation. Which begins ...

5 Outlining


nXML mode allows you to display all orpart of a buffer as an outline, in asimilar way to Emacs' outline mode.An outline in nXML mode is based onrecognizing two kinds of element:sections and headings. There is oneheading for every section and onesection for every heading. A sectioncontains its heading as or within itsfirst child element. A section alsocontains its subordinate sections (itssubsections). The text content of asection consists of anything in asection that is neither a subsectionnor a heading.

https://www.gnu.org/software/emacs/manual/html_mono/nxml-mode.html#Outlining


There finally is an answer athttps://emacs.stackexchange.com/questions/2884/the-old-how-to-fold-xml-question, using hideshow.

If and when the emacs.stackexchange gets out of its beta stage, this question might become obsolete.


If you only need to edit unspecified xml, I suggest using web-mode instead of nxml-mode. It supports node folding.

Emacs seems to open .xml files in nxml-mode by default. I guess nxml-mode is useful for working with xml validated against a schema. However, if you just want to edit some un-specified xml with convenient tools, it seems that web-mode may be a better choice.

I found this question searching for a way to do the latter, so I thought I'd share.