Get all nodes of particular name in lxml?

ArropeArounda

New Member
I'm finding the initial learning curve a bit steep with lxml - just common tasks such as grabbing nodes by name, attribute, and get their content. Here's a very simple question.I have an XML file. I would like to find all the XML nodes called \[code\]<Review>\[/code\]. How can I do this most efficiently with lxml?\[code\]f = open('./test.xml')xml = f.read()tree = etree.parse(StringIO(xml))context = etree.iterparse(StringIO(xml))# How to get all the tags with the name <Review>reviews = tree.findall('Review') # Something like this?\[/code\]I don't know if I should be using objectify, xpath... Comments also welcome on the way that I'm reading in the file and turning it into a parsable lxml object. Thanks.
 
Back
Top