简体   繁体   中英

Expat xml parser in python

When using expat xml parser in python, how can I get it store the parsed the xml data in a string or in a file or in any data structure. Please show me a way to accomplish how to parse and use the nodes of the xml data.

Why are you using a low-level interface like the expat parser when you can use xml.etree.[c]ElementTree? It creates a tree of elements (nodes) for you. Elements have tag, text, and tail attributes and contain a dict that maps attribute names to values, and a list of child elements.

Have a look at the Python documentation for xml.etree.ElementTree, and this additional information .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM