#!/usr/bin/env python # -*- coding: UTF-8 -*- # This script use to get the data from XML file and then put this data in a excel.
from xml.dom import minidom from pyExcelerator import* import sys import os import datetime import time
def getTagText(root,tag,current_time): Allnodes=root.getElementsByTagName(tag) w=Workbook() ws=w.add_sheet(current_time) row,col=1,1 for nodes in Allnodes: for node in nodes.childNodes: if node.nodeType != node.TEXT_NODE: #print node #print node.childNodes[0].data s=node.childNodes[0].data ws.write(row,col,s) col+=1 #next col # Reset next row row+=1 col=1 w.save('F:\\python\\xmldata\\'+current_time+'.xls')
#Format the time as 'YYmmddHHMMSS' def format_time(): x=time.localtime() t=datetime.datetime(*x[:6]) return t.strftime("%Y%m%d%H%M%S")