Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Something similar to PHP's SimpleXML in Python?

Is there a way in Python to handle XML files similar to the way PHP's SimpleXML extension does them?

Ideally I just want to be able to access certain xml datas from a list object.

like image 569
Ashy Avatar asked Nov 28 '08 22:11

Ashy


2 Answers

There is a long list of libraries associated with XML processing on the Python wiki. Note that a number of them are included in the standard library. Most of them will do what you are looking for:

to access certain xml datas from a list object

which is a bit vague, and perhaps some more concrete use-case might narrow down that list for you.

like image 188
Ali Afshar Avatar answered Oct 20 '22 09:10

Ali Afshar


You might want to try xml.etree.ElementTree It provides many easy ways to access read xml and to build new xml.

Or better yet use lxml.etree that provides even more convenient ways of accessing the nodes (such as xpath)

like image 37
Kamil Szot Avatar answered Oct 20 '22 09:10

Kamil Szot