<rule>
<vars>
<value>*</value>
<value>MAP</value>
<value></value>
<value>*</value>
<value>*</value>
<value>8795</value>
<value>4</value>
<value>*</value>
</vars>
</rule>
This is a fragment of my XML file. I have to refer to number between value tags. I want to find and delete code between rule tags. I try to do like this:
x = input("if find this value delete rule block ")
str(x)
for child in root.iter():
for rule in child.findall('rule'):
for vars in rule.findall('vars'):
val = str(vars.find('value'))
print(val)
if val == x:
root.remove(rule)
tree.write('output.xml')
So the problem is here: val = str(vars.find('value')), because when I run this code and print val PowerShell prints:
Element 'value' at 0x0328BFC0
for all value tags.