title: Modifying XML with ElementTree: 'str' object has no attribute 'text'
body: <p>The following code gives the error:
  line 19, in modifyXML
      self.PreFlopCallPower.text = 'NEW VALUE'
  AttributeError: 'str' object has no attribute 'text'</p>
  
  <p>The problem seems to be that self.PreFlopCallPower is only a string and not an elementTree object, even though my example is very similar to the example given on the python etree documentation: self.PreFlopCallPower = entry.find('PreFlopCallPower').text. How can I fix this? I can't see what I'm doing different to the update example listed here: <a href="https://docs.python.org/2/library/xml.etree.elementtree.html" rel="nofollow">https://docs.python.org/2/library/xml.etree.elementtree.html</a></p>
  
  <pre><code>import xml.etree.ElementTree as xml
  
  
  class XMLHandler(object):
      def __init__(self,StrategyName):
          self.readXML(StrategyName)
          self.modifyXML()
  
      def readXML(self, StrategyName):
          self.Template = StrategyName
          self.tree = xml.parse('strategies.xml')
          self.root = self.tree.getroot()
  
          for entry in self.root.findall('Strategy'):
              if entry.get('name') == StrategyName:
                  self.PreFlopCallPower = entry.find('PreFlopCallPower').text
  
      def modifyXML (self):
          self.PreFlopCallPower.text = 'NEW VALUE' # ---ERROR OCCURS HERE---
          self.PreFlopCallPower.set('updated', 'yes')
          self.tree.write('output.xml')
  
  
  X=XMLHandler('Strategy305PP')
  </code></pre>