This is an important pattern and comes up infrequently enough I’d better save a snippet…
from lxml import etree
import os
bigxml = os.path.abspath("C:\\Docume~1\\dmack\\Desktop\\seatmap\\projects\\reds\\redsVbrew269.xml")
doc = etree.parse(bigxml)
# Needles -- our various sections, each of which may be on any XML screen node.
a = ['BATEYE', 'BEERG', 'FRNTGT', 'GMGRST', 'PDECKA', \
'PDECKB', 'PLTHSE', 'RIVDEK', 'SPRSTE', 'SRO', \
'ST217A', 'ST217B', 'STE101', 'STE102', 'STE103', \
'STE104', 'STE105', 'STE106', 'STE107', 'STE108', \
'STE109', 'STE110', 'STE111', 'STE112', 'STE113', \
'STE114', 'STE115', 'STE116', 'STE117', 'STE118', \
'STE13', 'STE201', 'STE202', 'STE203', 'STE204', \
'STE205', 'STE206', 'STE207', 'STE208', 'STE209', \
'STE210', 'STE211', 'STE212', 'STE213', 'STE214', \
'STE215', 'STE216', 'STE218', 'STE219', 'STE220', \
'STE221', 'STE222', 'STE223', 'STE224', 'STE225', \
'STE226', 'STE227', 'STE228', 'STE229', 'STE230', \
'STE231', 'STE232', 'STE233', 'STE234', 'STE235', \
'STE236', 'STE237', 'STE238', 'STE24', 'STE8']
root = doc.getroot();
for screens in root[8]: # Haystack.
for lhs in screens[0]:
if (lhs[6].text in a):
print 'screen: ', screens.get('number'), ': ', lhs[6].text
0 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.
You must be logged in to post a comment.