Read, modify & save xml file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PythonUser1
    New Member
    • Jun 2008
    • 4

    Read, modify & save xml file

    Hi,

    Using Python, I want to read xml file from the disk, modify the values/add elements/attributes and save the xml back to disk.

    Please give me the sample source code for the same.

    Thanks,
  • kaarthikeyapreyan
    New Member
    • Apr 2007
    • 106

    #2
    You can make use of the the xml.dom or xml.dom.minidom to parse the xml files. If not successful try simple search and replace methods using file objects

    Comment

    • Laharl
      Recognized Expert Contributor
      • Sep 2007
      • 849

      #3
      Use minidom rather than dom, it's much more lightweight.

      Comment

      Working...