title: Trying to parse Word docx file as a zip document using Python's xml.elementtree
body: <p>I'm trying to parse a Windows docx file as a zip file using Python's xml.elementtree module.  I saved the docx file as a zip.  Below is what the document looks like:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="true"?&gt;
  &lt;?mso-application progid="Word.Document"?&gt;
  -&lt;pkg:package xmlns:pkg="http://schemas.microsoft.com/office/2006/xmlPackage"&gt;
  -&lt;pkg:part pkg:padding="512" pkg:contentType="application/vnd.openxmlformats-  package.relationships+xml" pkg:name="/_rels/.rels"&gt;
  +&lt;pkg:xmlData&gt;
  &lt;/pkg:part&gt;
  +&lt;pkg:part pkg:padding="256" pkg:contentType="application/vnd.openxmlformats-package.relationships+xml" pkg:name="/word/_rels/document.xml.rels"&gt;
  -&lt;pkg:part pkg:contentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml" pkg:name="/word/document.xml"&gt;
  -&lt;pkg:xmlData&gt;
  -&lt;w:document   xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:mv="urn:schemas-microsoft-com:mac:vml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mo="http://schemas.microsoft.com/office/mac/office/2008/main" xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" mc:Ignorable="w14 wp14"&gt;
  -&lt;w:body&gt;
  -&lt;w:p w:rsidP="00E65A71" w:rsidRDefault="00E65A71" w:rsidR="00E65A71"&gt;
  -&lt;w:r&gt;
   &lt;w:t&gt;Gloss:&lt;/w:t&gt;
   &lt;/w:r&gt;
   -&lt;w:r&gt;
   &lt;w:tab/&gt;
   &lt;/w:r&gt;
  -&lt;w:r w:rsidRPr="00EC6528"&gt;
  -&lt;w:rPr&gt;
   &lt;w:noProof/&gt;
   &lt;/w:rPr&gt;
   &lt;w:t&gt;the door&lt;/w:t&gt;
   &lt;/w:r&gt;
   &lt;/w:p&gt;
  -&lt;w:p w:rsidP="00E65A71" w:rsidRDefault="00E65A71" w:rsidR="00E65A71"&gt;
  -&lt;w:r&gt;
   &lt;w:t xml:space="preserve"&gt;Base: &lt;/w:t&gt;
   &lt;/w:r&gt;
  -&lt;w:r&gt;
   &lt;w:tab/&gt;
   &lt;/w:r&gt;
  -&lt;w:r w:rsidRPr="00EC6528"&gt;
  -&lt;w:rPr&gt;
   &lt;w:noProof/&gt;
   &lt;/w:rPr&gt;
   &lt;w:t&gt;words&lt;/w:t&gt;
   &lt;/w:r&gt;
  -&lt;w:r&gt;
  </code></pre>
  
  <p>As you can see I've minimized a few of the elements to save space.  I'm interested in the stuff in the</p>
  
  <pre><code>&lt;w:document&gt;&lt;w:body&gt;
  </code></pre>
  
  <p>elements specifically:</p>
  
  <pre><code>&lt;w:r&gt;&lt;w:t&gt;
  </code></pre>
  
  <p>that's where the data is that I want to parse.  I can't seem to get past the first element.  Below is what's tried to get at that stuff:</p>
  
  <pre><code>import xml.etree.ElementTree as ET
  tree = ET.parse('document.xml')
  body = tree.getroot().findall("w")
  #body = tree.getroot().findall(w:t)
  #body = tree.getroot()
  </code></pre>
  
  <p>and also:</p>
  
  <pre><code>for child in root:
     print child.tag, child.attrib
  </code></pre>
  
  <p>I've tried that just to see if I could see any of the elements I could then drill into but that returns nothing.  I've also tried other code but I can't seem to get to the stuff I want.  I've programmed a lot in Python put never used this module to parse XML.  I'm using VS studio 2012 with pytools and when I set a breakpoint and look at the "root" structure I can't seem to drill into the element I want to get.  I can't seem to navigate past the "pkg:package" stuff.  My end goal is to set up a for loop to work through the "" stuff that will be repeated throughout the document.  I've been researching this for a little while and trying to work through a few of the tutorials so any help is greatly appreciated!  Thanks.</p>