Chinaunix首页 | 论坛 | 博客
  • 博客访问: 150029
  • 博文数量: 44
  • 博客积分: 2085
  • 博客等级: 大尉
  • 技术积分: 455
  • 用 户 组: 普通用户
  • 注册时间: 2009-07-31 11:03
文章分类

全部博文(44)

文章存档

2013年(3)

2011年(8)

2010年(11)

2009年(22)

我的朋友

分类: Python/Ruby

2010-05-12 17:27:47

#!/usr/bin/python
import sys
from xml.dom import minidom
def findNode( in_parent, in_nodeName):
    """
    check wether the child node exist from paraent xml tree
    """
    if in_parent:
        for node in in_parent.childNodes:
            if node.nodeType == node.ELEMENT_NODE:
                if node.nodeName == in_nodeName:
                    return node
if __name__=="__main__":
    xml_fd   = minidom.parse('./b.xml')
    TargetBD = findNode(xml_fd, 'TargetBD')
    if(TargetBD == None):
       sys.exit(0)
    softwareReleaseVersion = TargetBD.getAttribute('softwareReleaseVersion')
    commandScriptName = TargetBD.getAttribute('commandScriptName')
    buildDescriptorId = TargetBD.getAttribute('buildDescriptorId')
    print softwareReleaseVersion
    print commandScriptName
    print buildDescriptorId
    buildElement = findNode(TargetBD, 'buildElement')
    if(buildElement == None):
       sys.exit(0)
    ElementCounts = TargetBD.getElementsByTagName("buildElement")
    for element in ElementCounts:
        softwareReleaseType = element.getAttribute('softwareReleaseType')
        softwareReleaseId = element.getAttribute('softwareReleaseId')
        softwareArchiveName = element.getAttribute('softwareArchiveName')
        print softwareReleaseType
        print softwareReleaseId
        print  softwareArchiveName
========================================================================
 
xml
================================




 
阅读(870) | 评论(0) | 转发(0) |
0

上一篇:tftp, sftp ,scp

下一篇:python 事例

给主人留下些什么吧!~~