FLEXPART Testing Environment CTBTO WO8
 All Classes Namespaces Files Functions Variables Pages
stuff.py
Go to the documentation of this file.
1 
2 """
3 Simple proof of concept program to show how we traverse the testing hierarchy
4 of an XML testing namelist
5 
6 Don Morton
7 Boreal Scientific Computing LLC, Fairbanks, Alaska, USA
8 Don.Morton@borealscicomp.com
9 
10 """
11 import xml.etree.ElementTree as ET
12 
13 tree = ET.parse('stuff2.xml')
14 root = tree.getroot()
15 
16 print 'root tag and attrib: '
17 print root.tag, root.attrib
18 
19 print 'Distribution variables:'
20 metcase_list = []
21 for child in root:
22  if child.text.strip():
23  print child.tag, child.text.strip()
24  if child.tag == "metcase":
25  print 'in metcase'
26  metcasechildren = child.getchildren()
27  print
28  print 'metcase:'
29  for m in metcasechildren:
30  print m.tag, m.text.strip()
31 
32  if m.tag == 'runcase':
33  runcasechildren = m.getchildren()
34  print
35  print 'in runcase:'
36  for r in runcasechildren:
37  print r.tag, r.text.strip()
38 
39  if r.tag == 'basictest':
40  basictestchildren = r.getchildren()
41  print
42  print 'in basictest'
43  for b in basictestchildren:
44  print b.tag, b.text.strip()
45 
46 '''
47 print 'tree.iter():'
48 for elem in tree.iter():
49  print elem.tag, elem.text
50 '''
51 
52 
53 
54 
55 
56 
57