Asked • 06/06/19

How do I parse XML in Python?

I have many rows in a database that contains 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?

1 Expert Answer

By:

James G. answered • 06/12/19

Tutor
5.0 (516)

Computer Science and Programming Tutor, Teacher, and Professional

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.