Python implements parsing cdatasection data based on XML parse _python

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.