Trying to use Python to parse a docx document in xml format to print words that are in bold
<p>I have a word docx file that I would like to print the words that are in <strong>Bold</strong> looking through the document in xml format it seems the words I'm looking to print have the following attribute.</p>

<pre><code>&lt;w:r w:rsidRPr="00510F21"&gt;
  &lt;w:rPr&gt;&lt;w:b/&gt;
     &lt;w:noProof/&gt;
     &lt;w:sz w:val="22"/&gt;
     &lt;w:szCs w:val="22"/&gt;
  &lt;/w:rPr&gt;
  &lt;w:t&gt;Print this Sentence&lt;/w:t&gt;
&lt;/w:r&gt;
</code></pre>

<p>Specifically the <code>w:rsidRPr="00510F21"</code> attribute which specifies that the text is bold.  Below is more of the XML document give a better idea of the structure.</p>

<pre><code>&lt;w:p w14:paraId="64E19BC3" w14:textId="4D8C930F" w:rsidR="00FF6AD1" w:rsidRDefault="00FF6AD1" w:rsidP="00C11B48"&gt;
&lt;w:pPr&gt;
   &lt;w:ind w:left="360" w:hanging="360"/&gt;
   &lt;w:jc w:val="both"/&gt;
   &lt;w:rPr&gt;
       &lt;w:sz w:val="22"/&gt;
       &lt;w:szCs w:val="22"/&gt;
   &lt;/w:rPr&gt;
 &lt;/w:pPr&gt;
 &lt;w:r&gt;
    &lt;w:rPr&gt;&lt;w:b/&gt;
       &lt;w:noProof/&gt;&lt;w:sz w:val="22"/&gt;
       &lt;w:szCs w:val="22"/&gt;
    &lt;/w:rPr&gt;&lt;w:t xml:space="preserve"&gt;Some text&lt;/w:t&gt;
 &lt;/w:r&gt;
 &lt;w:r w:rsidRPr="0009466D"&gt;
     &lt;w:rPr&gt;&lt;w:i/&gt;&lt;w:noProof/&gt;
          &lt;w:sz w:val="22"/&gt;&lt;w:szCs w:val="22"/&gt;
     &lt;/w:rPr&gt;
     &lt;w:t&gt;For example&lt;/w:t&gt;
 &lt;/w:r&gt;
 &lt;w:r&gt;
     &lt;w:rPr&gt;
        &lt;w:noProof/&gt;
        &lt;w:sz w:val="22"/&gt;
        &lt;w:szCs w:val="22"/&gt;
     &lt;/w:rPr&gt;&lt;w:t xml:space="preserve"&gt;
     &lt;/w:t&gt;
 &lt;/w:r&gt;
 &lt;w:r w:rsidRPr="00510F21"&gt;
     &lt;w:rPr&gt;
         &lt;w:b/&gt;
         &lt;w:noProof/&gt;
         &lt;w:sz w:val="22"/&gt;
         &lt;w:szCs w:val="22"/&gt;
     &lt;/w:rPr&gt;
     &lt;w:t&gt;Print this stuff&lt;/w:t&gt;
 &lt;/w:r&gt;
</code></pre>

<p>After doing some research and trying to do this with the Python-docx library I've decided to try using <code>lxml</code>.  I was getting an error about the namespace and tried to add that namespace but it's returning an empty set.  Below is some of the namespace stuff from the document.</p>

<pre><code>&lt;w:document
xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" 
xmlns:mo="http://schemas.microsoft.com/office/mac/office/2008/main" 
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
xmlns:mv="urn:schemas-microsoft-com:mac:vml" 
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" 
xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math"
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing"  xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" 
xmlns:w10="urn:schemas-microsoft-com:office:word" 
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" 
xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml"
xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"            xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk"
xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" 
xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape"
mc:Ignorable="w14 w15 wp14"&gt;
</code></pre>

<p>Below is the code I'm using.  Again I'd like to print if the attribute is <code>w:rsidRPr="00510F21"</code>.</p>

<pre><code>from lxml import etree
root = etree.parse("document.xml")

namespaces = {'w':'http://schemas.openxmlformats.org/wordprocessingml/2006/main'}

wr_roots = root.findall('w:r', namespaces)
print wr_roots # prints empty set

for atype in wr_roots:
   if w:rsidRPr == '00510F21':
       print(atype.get('w:t'))
</code></pre>