[XML-SIG] enumerate the attributes?

Mark McEahern marklists@mceahern.com
Thu, 6 Sep 2001 09:13:25 -0700


Hi, is there a way to enumerate the attributes of a node?

	from xml.dom import minidom

	s = "<foo id='1' width='2' height='3'/>"
	doc = minidom.parseString(s)

	foo = doc.documentElement

	# something like this:
	for a in foo.attributes:
		print "%s = %s" % (a.name, a.value)

	# ideally, attributes would be a dictionary too:
	a = "id"
	print "%s = %s" % (a, foo.attributes[a])

Thanks,

// mark