I've recently started using nxml-mode, and one function I quickly
felt a need for is one which compactly indicates where in the
structure we currently are. For example,
<e>
<a>
<b>
oh
</b>
<c/>
<d>
point is here
</d>
</a>
</e>
The command in question should show something like /e/a/d, i.e.,
an XML path to the current element. Has anyone written such a
function? Actually, I just did myself, but it feels like a rough and
error-prone attempt. Since it's very small, I'll enclose it here:
(defun show-xml-path (arg)
"Shows the names of all elements enclosing point, in the echo area."
(interactive "*P")
(let ((q ""))
(nxml-ensure-scan-up-to-date)
(setq q "")
(condition-case ()
(save-excursion
(while t
(nxml-backward-up-element)
(setq q (concat (xmltok-start-tag-qname) "/" q))))
(error (message q)))))
I know there is a mailing-list for nxml-mode, but searching it didn't
turn up anything like this.
/Arndt Jonasson