The example of this article describes Python based on XML parse to realize the method of parsing cdatasection data, share it for everyone's reference.
The implementation methods are as follows:
From xml.dom.minidom import * implementation = Domimplementation () print "core:%s"% implementation.hasfeature (' Cor E ', ' 2.0 ') print "events:%s"% implementation.hasfeature (' Events ', ' 2.0 ') print "traversal:%s"% Implementation.hasfeatu Re (' 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_tagna
Me () print "child_get_localname:%s"% child._get_localname () print "child.haschildnodes:%s"% child.haschildnodes () If child._get_tagname () = = "Files_rg": Files = child._get_childnodes () for file in Files:if File.node Type = = dom.
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._ge
T_data ())
I hope this article will help you with your Python programming.