Python's lxml and iterparse method?

How about: import io import lxml. Etree as ET content='''\ text_value1 text_value2 some_text ''' contentBuffer=io. BytesIO(content) context = ET.

Iterparse(contentBuffer,tag='result') for action, elem in context: fields=elem. Xpath('field/@k') values=elem. Xpath('field/value/text/text()') for field,value in zip(fields,values): print('\t{f} = {v}'.

Format(f=field,v=value)) which yields field1 = text_value1 field2 = text_value2 field3 = some_text.

Perfect! Thank you sir. – nnachefski Mar 31 at 15:42.

I would suggest to use a XPath query (lxml.de/xpathxslt.html). Something along r = tree. Xpath('//text') should be sufficient for your needs.

So basically, I want to iterate over ever result set, then iterate over every field in that result set and print the text data. Any help would be greatly appreciated.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions