Skip to main content
2 of 9
Change the final question to make it more constructive.
dmeister
  • 35.9k
  • 19
  • 76
  • 98

easiest way to parse xml in python

I have many rows in a database that contain xml and I'm trying to write a python script that will go through those rows and count how many instances of a particular node attribute show up. for instance, my tree looks like:

<foo> <bar> <type foobar="1"/> <type foobar="2"/> </bar> </foo> 

How can I access the attributes 1 and 2 in the XML using Python?

randombits
  • 48.7k
  • 79
  • 275
  • 450