XML : How to create xml in Python dynamically?

  import xml.etree.ElementTree as ET  try:  guess_row=int(input("Enter the number of Element for XML files: -    \n"))    var3 = raw_input("Enter the root Element: \n")  root = ET.Element(var3)  #doc = ET.SubElement(root,"maya")  var = raw_input("Enter Element: - \n")  var1 = raw_input("Enter Data: - \n")    ET.SubElement(root, var).text =var1    tree = ET.ElementTree(root)  tree.write("filename.xml")    print "Xml file Created..!!"  except ValueError:  print("Occured Error")    

I am new to python just i need to create xml file using python dynamically where i want to give inputs from the console. Once create the xml file need to read entire file and modify the same dynamically. I am not getting where stuck. How it should get solved?

No comments:

Post a Comment