Attributes as a map (ignoring malformed attributes)

var xml = """
<student first="Snow" last="Man"/>
""".to_xml

var attributes = xml["student"].first.as(XMLAttrTag).attributes_to_map
assert attributes.join(", ", ":") == "first:Snow, last:Man"

Property definitions

dom :: dom $ XMLAttrTag :: attributes_to_map
	# Attributes as a map (ignoring malformed attributes)
	#
	# ~~~
	# var xml = """
	# <student first="Snow" last="Man"/>
	# """.to_xml
	#
	# var attributes = xml["student"].first.as(XMLAttrTag).attributes_to_map
	# assert attributes.join(", ", ":") == "first:Snow, last:Man"
	# ~~~
	fun attributes_to_map: Map[String, String]
	do
		var m = new Map[String, String]
		for a in attributes do
			if a isa XMLStringAttr then
				m[a.name] = a.value
			end
		end
		return m
	end
lib/dom/dom.nit:73,2--92,4