I am getting a path separator error in python 2.6.1. I have not found this issue with python 2.7.2 version, but unfortunately I need this in 2.6.1 only. Is there any another way to achieve the same? :(
my code :-
import xml.etree.ElementTree as ET #version 1.2.6
import sys
class usersDetail(object):
def __init__(self, users=None):
self.doc = ET.parse("test.xml")
self.root = self.doc.getroot()
def final_xml(self,username):
r = self.root.find("user[@username='user1']") #not working in 2.6.1 :(
self.root.remove(r)
print r
tree = ET.ElementTree(self.root)
tree.write("msl.xml")
if __name__ == '__main__':
parser = usersDetail()
parser.final_xml("user1")
test.xml is :-
<?xml version="1.0"?>
<users>
<user afp="yes" cifs="yes" username="user1" volume="vol" webdev="yes" /></user>
</users>
What this will do is it will remove the xml only if username = username. Thanks in advance for your valuable time.