首页 > 其他 > 详细

XML文件解析

时间:2016-05-05 12:42:43      阅读:85      评论:0      收藏:0      [点我收藏+]
 
#resthread.xml
<?xml version=1.0 encoding=UTF-8?>
<limit>
    <data name=thread_nu value=3 />
</limit>
from xml.dom.minidom

def getConfig():
    xml_path = resthread.xml
    config = {}
    root = xml.dom.minidom.parse(xml_path)
    xml_root = root.documentElement
    nodes = xml_root.getElementsByTagName(data)
    for node in nodes:
        config[node.getAttribute(name)] = node.getAttribute(value)
    return config

def threadNu():
    config = {}
    config = getConfig()
    nu = config[thread_nu]

 

XML文件解析

原文:http://www.cnblogs.com/xzhdream/p/5461126.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!