<doc id="1"> # id is attribute of doc
<text> blahblah </text> # text is element of doc
<doc id="3">
<text> blahblah2 </text>
docs = root.findall('./docs/doc')
row = []
for doc in docs: # retrieve attrib of doc
id = doc.attrib['id']
#retrieve element text from doc && record contents using .text
txt = doc.find('./text').text
row.append({'id': id, 'text': txt})




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

The Proper Way To Send Email — NodeJs & AWS

Flash Code#1 Drag&Drop Component Using Vue.js

Difference between Browser JS(console) vs Nodejs

A Simple Guide to Add FontAwesome in Angular

What is JavaScript ?

10 Popular JavaScript Interview Question and Answer

React Router Paths

Avoid These 4 Common React Native App Development Mistakes

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Tina Huang

Tina Huang

More from Medium

Ghazal: To Be Teased into DisUnity

Workflow Webinar : DVD player


Bit-Masking To Generate Subsets