What's the best way to read XML in Python? Need help parsing! or How do I read XML files in Python ef

20 Replies, 1971 Views

lxml is *chef's kiss* for *read xml python* tasks. Yeah, it's external, but the XPath support alone makes it worth it.

```python
from lxml import etree
doc = etree.parse('file.xml')
```
Way cleaner than ET for complex stuff.

Also, check out `xmltodict` if you wanna treat XML like JSON. Lifesaver for quick hacks!

Messages In This Thread



Users browsing this thread: 1 Guest(s)