Note : Python has several ways of parsing XML, and the following "ET" represents the Library "ElementTree" (Import Xml.etree.ElementTree as ET)
1. Et_tree = Et.parse (' Xxx.xml '): The parameter is a stream object or file name that returns an entire XML file object.
2. Et_root = Et_tree.getroot (): Gets the root node, the following is the node usage as an example of the root node et_root.
> Len (et_root): Number of direct child elements;
> For Child_node in Et_root: Iterates through the nodes of each of the immediate child elements;
> Et_root.attrib: Returns a dictionary of the node's property names and their values;
> Et_root[3]: Returns the immediate child element node of the specified index;
> Et_root.find (node_name): Finds the first matching immediate child element node under a node, and returns none if there is no child node or if the node does not have a child node at all;
> Et_root.findall (node_name): Finds all the immediate child element nodes under the node, if the node name is preceded by a double slash, it means to find all the child elements under the node, not just the immediate child elements, such as: Et_root.findall ('/// Author '), which indicates that all child nodes named "Author" are found under the Et_root node;
> Et_root.text: Returns the text content of the node (if any);
3.
Python's XML