title: Read XML file which has xmlns in tag with python
body: <p>I am trying to read a element form a xml file to add new elements.</p>
  
  <p>The tag I'm trying to find contains xmlns.</p>
  
  <p>It looks like this:</p>
  
  <pre><code>&lt;labcore.logging.service defaultSystemIdentificationCode="??" xmlns="http://schemas.com/labcore/configuration"&gt;
  &lt;storage databaseName="COMIT" storageType="Oracle" /&gt;
  &lt;logEventDefinitions&gt;
  
              &lt;logEventDefinition assembly="IM.LogEventDefinitions" /&gt;                    
              &lt;logEventDefinition assembly="BarcodeEntry.LogEventDefinitions" /&gt;                  
              &lt;logEventDefinition assembly="MaintenanceScheduling.ActivityLog.Messages.LogEventDefinitions" /&gt;
              &lt;logEventDefinition assembly="InCore.LogEventDefinitions" /&gt;    
  
  
    &lt;logEventDefinition assembly="LogEventPackage.LogEventDefinitions" /&gt;
  &lt;/logEventDefinitions&gt;
  </code></pre>
  
  <p>and my python code looks like this:</p>
  
  <pre><code>import xml.etree.ElementTree as xml
  
  def modifyComitLoggingConfigFile(filePath, fileName):
  
      path = filePath+"\\"+fileName
  
      IM = xml.Element("logEventDefinition")
      IM.attrib["assembly"] = "IM.LogEventDefinitions"
  
      BarcodeEntry = xml.Element("logEventDefinition")
      BarcodeEntry.attrib["assembly"] = "BarcodeEntry.LogEventDefinitions"
  
      MaintenanceScheduling = xml.Element("logEventDefinition")
      MaintenanceScheduling.attrib["assembly"] = "MaintenanceScheduling.ActivityLog.Messages.LogEventDefinitions"
  
      RTCosmo3 = xml.Element("logEventDefinition")
      RTCosmo3.attrib["assembly"] = "InCore.LogEventDefinitions"
  
      tree = xml.parse(path)
      rootElement = tree.getroot()
  
      loggingTag = rootElement.find("labcore.logging.service")
      print "loggingTag"
      print loggingTag
      print
  
      logEventDefinitionsTag = loggingTag.find("logEventDefinitions")
      print "logEventDefinitionsTag"
      print logEventDefinitionsTag
      print
  
      logEventDefinitionsTag.insert(0, RTCosmo3)
      logEventDefinitionsTag.insert(0, MaintenanceScheduling)
      logEventDefinitionsTag.insert(0, BarcodeEntry)        
      logEventDefinitionsTag.insert(0, IM)
  
      print "definitionfilesTag"
      print logEventDefinitionsTag
      print
  
      print "xml.tostring of definitionfilesTag"
      print xml.tostringlist(logEventDefinitionsTag)
      print
  
      tree.write(path+"1")
      return
  </code></pre>
  
  <p>and at the following line:</p>
  
  <pre><code>import xml.etree.ElementTree as xml
  
  def modifyComitLoggingConfigFile(filePath, fileName):
  
      path = filePath+"\\"+fileName
  
      IM = xml.Element("logEventDefinition")
      IM.attrib["assembly"] = "IM.LogEventDefinitions"
  
      BarcodeEntry = xml.Element("logEventDefinition")
      BarcodeEntry.attrib["assembly"] = "BarcodeEntry.LogEventDefinitions"
  
      MaintenanceScheduling = xml.Element("logEventDefinition")
      MaintenanceScheduling.attrib["assembly"] = "MaintenanceScheduling.ActivityLog.Messages.LogEventDefinitions"
  
      RTCosmo3 = xml.Element("logEventDefinition")
      RTCosmo3.attrib["assembly"] = "InCore.LogEventDefinitions"
  
      tree = xml.parse(path)
      rootElement = tree.getroot()
  
      loggingTag = rootElement.find("labcore.logging.service")
      print "loggingTag"
      print loggingTag
      print
  
      logEventDefinitionsTag = loggingTag.find("logEventDefinitions")
      print "logEventDefinitionsTag"
      print logEventDefinitionsTag
      print
  
      logEventDefinitionsTag.insert(0, RTCosmo3)
      logEventDefinitionsTag.insert(0, MaintenanceScheduling)
      logEventDefinitionsTag.insert(0, BarcodeEntry)        
      logEventDefinitionsTag.insert(0, IM)
  
      print "definitionfilesTag"
      print logEventDefinitionsTag
      print
  
      print "xml.tostring of definitionfilesTag"
      print xml.tostringlist(logEventDefinitionsTag)
      print
  
      tree.write(path+"1")
      return
  </code></pre>
  
  <p>and on the following line:</p>
  
  <pre><code>loggingTag = rootElement.find("labcore.logging.service")
  </code></pre>
  
  <p>the following error occurs:</p>
  
  <pre><code>AttributeError: 'NoneType' object has no attribute 'find'
  </code></pre>
  
  <p>but when i remove the <code>xmlns</code> part from the tag, it works. does anybody know how i can solve this?</p>