XML data and ElementTree
New APIs often speak JSON, but many regulated corners of the world still ship XML: a bank's rate feed, an enterprise invoice, a years-old integration nobody dares rewrite. The format is deliberately hierarchical—elements inside elements, attributes on tags—so contracts can be nailed down with schemas (XSD) and validators in a way JSON ecosystems sometimes add later.
In Python you step into that world with xml.etree.ElementTree: parse once, walk children, read element.attrib like a dict, and pull text from .text (remembering that mixed content splits text across children and tail segments). Namespaces show up as tags like {uri}local, so real pipelines learn to compare the local name after the closing }.
When the file is gigabytes instead of kilobytes, the story changes: loading the whole tree can exhaust memory, and iterparse lets you stream and react instead of memorizing the entire document.
Many newer services expose JSON instead; requests, JSON APIs, and robust fetching covers that path. Reference: [1].
Sources
Tasks
Card Info
- Topic: Data Science Praktikum
- Difficulty: Intermediate
- Completed: 2 users