Python: Extract info from xml to dictionary <p>I need to extract information from an xml file, isolate it from the xml tags before and after, store the information in a dictionary, then loop through the dictionary to print a list. I am an absolute beginner so I'd like to keep it as simple as possible and I apologize if how I've described what I'd like to do doesn't make much sense.</p> <p>here is what i have so far.</p> <pre><code>for line in open("/people.xml"): if "name" in line: print (line) if "age" in line: print(line) </code></pre> <p>Current Output:</p> <pre><code> &lt;name&gt;John&lt;/name&gt; &lt;age&gt;14&lt;/age&gt; &lt;name&gt;Kevin&lt;/name&gt; &lt;age&gt;10&lt;/age&gt; &lt;name&gt;Billy&lt;/name&gt; &lt;age&gt;12&lt;/age&gt; </code></pre> <p>Desired Output</p> <pre><code>Name Age John 14 Kevin 10 Billy 12 </code></pre> <p>edit- So using the code below I can get the output:</p> <pre><code>{'Billy': '12', 'John': '14', 'Kevin': '10'} </code></pre> <p>Does anyone know how to get from this to a chart with headers like my desired output?</p>