Python parsing cdatasection data based on XML parse implementation

Source: Internet
Author: User
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.

  • 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.