Basically what I'm trying to do is import an xml file into Python and remove any data where the entityNo is 1111111111.
Here is a text copy of the xml data:
<memberBasedResearchDataImport>
<surveyDescr>D520</surveyDescr>
<surveyType>MEG</surveyType>
<surveyRequester>1543588274</surveyRequester>
<product>DISC</product>
<externalRef>PKG_RPTA88425_4</externalRef>
<DateTimeCreated>20191019 05:10:33</DateTimeCreated>
<identifierSettings>
<identifierType id="1" database="DARE" schema="dp_da_crm" table="ratings" column="object_cd" columnType="number"></identifierType>
<identifierType id="2" database="DARE" schema="dp_da_ent" table="entity" column="full_name" columnType="varchar2"></identifierType>
<identifierType id="3" database="dual" schema="dual" table="dual" column="dual" columnType="varchar2"></identifierType>
</identifierSettings>
<row id="1" entityNo="1054354679" entityRole="KP" policyNo="0" agentEntityNo="1103354880">
<templateValue name="INTERACTION_DAY" value="Friday"></templateValue>
<identifierType id="1" value="671535634817"></identifierType>
<identifierType id="2" value="CUSTOMER SERVICES: SALES"></identifierType>
</row>
<row id="2" entityNo="1111111111" entityRole="AP" policyNo="0" agentEntityNo="11351512571">
<templateValue name="INTERACTION_DAY" value="Friday"></templateValue>
<identifierType id="1" value="6715354549"></identifierType>
<identifierType id="2" value="CUSTOMER SERVICES: ADMIN"></identifierType>
</row>
<row id="3" entityNo="100000571" entityRole="LP" policyNo="0" agentEntityNo="112355274">
<templateValue name="INTERACTION_DAY" value="Friday"></templateValue>
<identifierType id="1" value="671546864"></identifierType>
<identifierType id="2" value="CUSTOMER SERVICES: SALES"></identifierType>
</row>
<row id="4" entityNo="1111111111" entityRole="HP" policyNo="0" agentEntityNo="112456466850"><templateValue name="INTERACTION_DAY" value="Friday"></templateValue>
<identifierType id="1" value="6793437110"></identifierType>
<identifierType id="2" value="CUSTOMER SERVICES: RETURNS"></identifierType>
</row>
</memberBasedResearchDataImport>
So far I have tried a few solutions that I have found online but with no success. The code below is what I found in another post but doesn't remove the data I need it to remove. My code is below and any help would be highly appreciated. Again, I need to delete the data where the entityNo = 1111111111 and then export the data in xml format.
from xml.etree.ElementTree import ElementTree
path_to_xml_file = "C:\Users\username\Documents\Data_File.xml"
tree = ElementTree()
tree.parse(path_to_xml_file)
foos = tree.findall("entityNo")
for foo in foos:
bars = foo.find("1111111111")
for bar in bars:
foo.remove(bar)
tree.write("C:\Users\username\Documents\Data_File.xml")