title: Creating xml doc with python/ElementTree and namespaces
body: <p>I'm trying to create an in-memory xml document such that the root's child nodes all require a name space.</p>
  
  <p>The final document should look something like this:</p>
  
  <pre><code>&lt;Feed&gt;            
  &lt;FeedEntity Id="0000" 
        xmlns="http://schemas.example.com/search/query/2010/5/revision"&gt;
  
      &lt;FeedRequest locale="en-US" title="&lt;some value&gt;"/&gt;
  &lt;/FeedEntity&gt;
  ... another FeedEntity element ...
  &lt;/Feed&gt;            
  </code></pre>
  
  <p>However, when I print out the document I've created with ElementTree lib, it looks more like this:</p>
  
  <pre><code>&lt;Feed&gt;
      &lt;ns0:FeedEntity Id="0000"
        xmlns:ns0="http://schemas.example.com/search/query/2010/5/revision"&gt;
  
          &lt;FeedRequest locale="en-US" title="&lt;some value&gt;"/&gt;
      &lt;/ns0:FeedEntity&gt;
  &lt;/Feed&gt;
  </code></pre>
  
  <p>Here's how I'm creating the document:</p>
  
  
  
  <pre><code>counter = 0
  namespace = "http://schemas.example.com/search/query/2010/5/revision"
  
  root = Element("Feed")        
  
  node_name = "{%s}FeedEntity" % (namespace, );                
  feed_entity_element = Element(node_name)        
  
  feed_entity_element["Id"] = "%04d" % (counter,);
  
  feed_request_element = Element("FeedRequest");
  feed_request_element["Culture"] = self.culture;
  feed_request_element["Query"] = address;        
  
  # append each of the elements to the xml document 
  feed_entity_element.append(feed_request_element);
  
  root.append(feed_entity_element);
  
  str_data = ET.tostring(root)
  print str_data
  </code></pre>
  
  <p>How do I get rid of the "ns0" parts in the final XML so it looks more like the first example noted above?</p>