python 解析xml (dom)
from xml.dom import minidomtry:
xmlfile = open("path.xml", "a+")
#xmldoc = minidom.parse( sys.argv)
xmldoc = minidom.parse(xmlfile)
except :
#updatelogger.error( "Can't parse Xml File." )
sys.exit(0)
ClientOutputPath = xmldoc.getElementsByTagName('D').attributes['path'].value
OutputPath = xmldoc.getElementsByTagName('h').attributes['path'].value
BasePath = xmldoc.getElementsByTagName('th').attributes['path'].value
ToolPath = xmldoc.getElementsByTagName('ub').attributes['path'].value
ToolPath_2 = xmldoc.getElementsByTagName('ub').attributes['path'].value
ClientOutputPath.replace( "\\", "\\\\" )
OutputPath.replace( "\\", "\\\\" )
BasePath.replace( "\\", "\\\\" )
ToolPath.replace( "\\", "\\\\" )
print ClientOutputPath
print OutputPath
print BasePath
print ToolPath
print ToolPath_2
页:
[1]