Famous Guacamole
A southwest favorite!
Combine all ingredients and hand whisk to desired consistency.
Serve and enjoy with ice-cold beers.
下面是我写的Python解析该大型XML的代码,但是结果却是错误的。求斧正,不胜感激!
from xml.etree.ElementTree import iterparse
ns={'t':'http://www.dabeaz.com/namespaces/recipe'}
iparse=iterparse('2.xml',['start','end'])
for event,elem in iparse:
if event =='start' and elem.tag == ‘{http://www.dabeaz.com/namespaces/recipe}r:ingredients':
nodes=elem
print 'nodes ',nodes
break
items=(elem for event,elem in iparse if event == 'end' and elem.tag =='{http://www.dabeaz.com/namespaces/recipe}r:item')
print items
for item in items:
num=item.get('num')
units=item.get('units')
text=item.text
print('%s%-5s%-5s'%(num,units,text))
nodes.remove(item)