1. 程式人生 > >python 之 如何通過指令碼讀取xml檔案節點

python 之 如何通過指令碼讀取xml檔案節點

#!/usr/bin/env python # -*- coding: utf-8 -*- #coding=utf-8

#寫指令碼的時候習慣把自己常用的模組都import進來了 import sys import sre_compile import re import pdb import os import codecs import time import datetime #注意:儘量使用C語言實現的那種,因為它速度更快,而且消耗的記憶體更少。 try:     import xml.etree.cElementTree as ET except ImportError:     import xml.etree.ElementTree as ET

profile = r'E:\abc.xml'

buildxml = ET.parse(profile).getroot()

for child in buildxml.findall('timenode'):     if (child.text != ''):         print "timenode 節點存在"