Python parsing of XML

Common DOM and XML programming interfaces SAX, these two different interfaces handles XML file, of course, the use of different occasions.

There are three ways Python parsing XML, SAX, DOM, and ElementTree:

1.SAX (simple API for XML )

Python standard library contains SAX parser, SAX event-driven model, triggered by one event in the process of parsing XML and calling user-defined callback functions to handle XML file.

2.DOM(Document Object Model)

The XML data is parsed into a tree in memory, through the operation of the tree to manipulate XML.

3.ElementTree (element tree)

ElementTree as a lightweight DOM, convenient and friendly API. Code is good availability, speed, consumption of shellfish warehouse less memory.

Guess you like

Origin www.cnblogs.com/C2020/p/12075206.html