XML Mode - get all attributes

Hi there,

is there a way to get all xml attributes with their values at the current cursor position?

The statement <mytag id="1" name="Test"/> should be parsed into something like:

{
id: “1”,
name: “Test”
}

Thanks for any help or suggestions!

Nope. You’ll have to do some parsing yourself.

Thanks for your reply: here is my approach - maybe it helps someone:

cm.on("cursorActivity", function () {
	var cur = cm.getCursor(),
		tagList = [
			"control",
			"fql",
			"text"
		],
		range = cm.getViewport(),
		attributes = {};

	range.from = Math.min(range.from, cur.line);
	range.to = Math.max(cur.line + 1, range.to);

	var match = CodeMirror.findMatchingTag(cm, cur, range);

	if (match && match.at === "open" && tagList.indexOf(match.open.tag.toLowerCase()) > -1) {
		var doc = cm.getDoc(),
			tagLine = doc.getRange(match.open.from, match.open.to, false).join(""),
			re = /(\S+)\s*?=\s*(['"])(.*?|)\2/g,
			m;

		while ((m = re.exec(tagLine)) !== null) {
			if (m.index === re.lastIndex) {
				re.lastIndex++;
			}

			attributes[m[1]] = m[3];
		}

		console.log(attributes);
	}
});