I'm tryin to retrieve some informations from an XML file with python. All i want is to set a pandas DataFrame with all the PrdRef infos that are related to a NIR tag matching with his 'Text()'
<Ressources xmlns="http://www.johndo.tr/brm">
...
<RessInd>
<CdRet>01</CdRet>
<NIR>456464644466</NIR>
<DTO>01011988</DTO>
<PrdRef>
<PrdRefTyp>M</PrdRefTyp>
<PrdRefVal>21M01</PrdRefVal>
...
</PrdRef>
</RessInd>
<RessInd>
... etc
</RessInd>
here is my code :
import pandas as pd
df_prdref = pd.read_xml("to_parse.xml",xpath="//data:PrdRef/../data:RessInd/data:NIR[text()='456464644466']",namespaces={"data": "http://johndo.tr/brm"})
print(df_prdref )
Unfortunatly no matter what i've tried, read_xml() always return error or nothing ..