国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

python基于xml parse實現解析cdatasection數據

2020-02-23 06:02:03
字體:
來源:轉載
供稿:網友

本文實例講述了python基于xml parse實現解析cdatasection數據的方法,分享給大家供大家參考。

具體實現方法如下:

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 child._get_tagName() == "files_rg":     files = child._get_childNodes()     for file in files:       if file.nodeType == 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._get_data()) 

希望本文所述對大家的Python程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 泉州市| 霍城县| 涪陵区| 建湖县| 尚志市| 赣州市| 新泰市| 建德市| 临潭县| 东乡| 许昌县| 江山市| 南昌县| 和田市| 阜阳市| 涟水县| 洛阳市| 平南县| 黔南| 普洱| 莱州市| 商城县| 时尚| 博罗县| 溆浦县| 鹿泉市| 原阳县| 武强县| 德钦县| 馆陶县| 收藏| 新竹市| 康马县| 西昌市| 黎城县| 五家渠市| 德昌县| 北安市| 九龙县| 普陀区| 宝丰县|