Struggling with parsing XML in Python lxml? Need help with XPath or performance tips? or What’s the b

16 Replies, 1194 Views

If your XPath returns empty, try `.//` instead of `//`—sometimes it’s a scope thing. Also, `*` in XPath can save you when tags are unpredictable.

For performance, `lxml` is already pretty optimized, but if it’s still slow, maybe pre-process the XML with `sed` or `awk` to strip crap you don’t need.

Namespaces? I just ignore ’em and use `local-name()` like a caveman. Works 60% of the time, every time.

Messages In This Thread



Users browsing this thread: 1 Guest(s)