This paper describes the method of Python parsing cdatasection data based on XML parse, and shares it for everyone's reference.
The implementation method is as follows:
From xml.dom.minidom import * implementation = Domimplementation () print "core:%s"% implementation.hasfeature (' Core ', ' 2.0 ') print "events:%s"% implementation.hasfeature (' Events ', ' 2.0 ') print "traversal:%s"% implementation.hasfeature (' Traversal ', ' 2.0 ') print "views:%s"% implementation.hasfeature (' views ', ' 2.0 ') print "features:%s"% implementation._ Features dom = Parse ("result.xml") Domroot = dom.documentelement print domroot print domroot.nodetype print "ELEMENT _node:%s "% dom. Element_node print "attribute_node:%s"% dom. Attribute_node children = Domroot.childnodes for child in Children:print "child_get_tagname:%s"% child._get_tagname () Print "child_get_localname:%s"% child._get_localname () print "child.haschildnodes:%s"% child.haschildnodes () if C Hild._get_tagname () = = "Files_rg": Files = child._get_childnodes () for file in files:if File.nodetype = = Do M.element_node:for NODE in File._get_childnodes (): print "Node.childnodEs:%s ", Node._get_childnodes () for cdatasection in Node._get_childnodes (): If Cdatasection.nodetype = = dom. Cdata_section_node:print "cdatasection._get_data:%s%s"% (Cdatasection._get_localname (), CdataSection._get _data ())
Hopefully this article will help you with Python programming.