• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Working with XML files in Python

Jeff7181

Lifer
Is there an accepted standard way to work with XML files in Python? Google searches keep turning up ElemenTree and LXML. Is there no native way to read and write XML files with Python?

(I'm used to PowerShell, where Export-Clixml and Import-Clixml are baked into PowerShell)
 
Last edited:
ElementTree seems to be a part of standard Python library. Seems reasonable for a standard xml library.

What do you mean by "native"?
 
ElementTree seems to be a part of standard Python library. Seems reasonable for a standard xml library.

What do you mean by "native"?

Admittedly I haven't even tried working with it yet, but it sounded to me like it was a module I had to add.

By native, I meant out of the box, no matter what OS, what distro, or how it's packaged, it can read/write XML files. If ElemenTree is included with Python, I suppose that answers my question.
 
I would recommend two things for working with python/xmls:

1. install PIP. this allows quick and easy installs of all modules
2. then run "pip install beautifulsoup4".

Beautifulsoup and beautifulstonesoup are excellent (albeit strangely named) modules for handling html and xml files in python. you won't find better. 🙂
 
Admittedly I haven't even tried working with it yet, but it sounded to me like it was a module I had to add.

By native, I meant out of the box, no matter what OS, what distro, or how it's packaged, it can read/write XML files. If ElemenTree is included with Python, I suppose that answers my question.

You have to import ElementTree, but you shouldn't have to download the module or anything, just do an import statement.
 
Back
Top