<server>
<User>
<Username>user</Username>
<Password>pass</Password>
<list>
<Item c="ru" askstatus="-1" recvstatus="-1" substatus="3" name="Roman"> </Item>
<Item c="ru" askstatus="-1" recvstatus="-1" substatus="3" name="Roman"> </Item>
<Item c="ru" askstatus="-1" recvstatus="-1" substatus="3" name="Roman"> </Item>
<Item c="com askstatus="-1" recvstatus="-1" substatus="3" name="Roman"> </Item>
</list>
</User>
</server>
#!/usr/bin/env python
import xml.etree.ElementTree as etree
import sys
tree = etree.parse(sys.argv[1])
root = tree.getroot()
for user in root:
for param in user:
if param.tag == 'list':
for item in param:
if str(item.get('c')) == 'ru':
param.remove(item)
tree.write('output.xml')
def __getitem__(self, index ):
return self._children[index]