[XML-SIG] enumerate the attributes?

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


Well, there is:

	foo._attrs

// m

> -----Original Message-----
> From: xml-sig-admin@python.org [mailto:xml-sig-admin@python.org]On
> Behalf Of Mark McEahern
> Sent: Thursday, September 06, 2001 9:13 AM
> To: xml-sig@python.org
> Subject: [XML-SIG] enumerate the attributes?
> 
> 
> 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
> 
> _______________________________________________
> XML-SIG maillist  -  XML-SIG@python.org
> http://mail.python.org/mailman/listinfo/xml-sig
>