#!/usr/bin/evn python
#coding:utf-8
try:
import xml.etree.cElementTree as ET
except ImportError:
import xml.etree.ElementTree as ET
import sys
try:
tree = ET.parse("test.xml") #打开xml文档
root = tree.getroot() #获得root节点
except Exception, e:
print "Error:cannot parse file:country.xml."
sys.exit(1)
for country in root.findall('sale'): #找到root节点下的所有sale节点
sale_nameid = country.find('nameid').text #子节点下节点nameid的值
print sale_nameid