XML : replace data in xml file using python

I have a xml file which has a path name which i would want to replace by another path name.My xml looks like below

  <company>   <name>comp_name</name>    <path><Pre-recorded>False</Pre-recorded>     <wfmpath>'C:\Users\Public\wfm.csv'</wfmpath>                  </path>   </company>    

when Pre-recorded is False, wfmpath should change to 'c:\Users\Public\my_wfm.csv'

I tried with this,but did not succeed!Please suggest

  def readwfmpath(self,path):      doc = minidom.parse("configurations.xml")      #name = doc.getElementsByTagName("name")[0]      staff = doc.getElementsByTagName("Pre-recorded")[0].firstChild.data      if staff == "True":          wfmpath = doc.getElementsByTagName("wfmpath")[0].firstChild.data      else:          wfmpath = doc.getElementsByTagName("wfmpath")[0].firstChild.data          wfmpath.replaceChild(path)      return wfmpath    

No comments:

Post a Comment