Answer the question
In order to leave comments, you need to log in
parsing xml. How to get around the problem with one position in the document?
I am learning python, in terms of parsing xml and entering data into the database.
for parsing, I use the xmltodict library, because it parses the file and provides it as a dictionary.
<wb:Content>
<wb:Position>
<wb:Identity>1</wb:Identity>
<wb:Product>
<pref:Type>АП</pref:Type>
<pref:FullName>Название</pref:FullName>
<pref:AlcCode>0323103000001227178</pref:AlcCode>
<pref:Capacity>0.500</pref:Capacity>
<pref:UnitType>Packed</pref:UnitType>
<pref:AlcVolume>4.000</pref:AlcVolume>
<pref:ProductVCode>500</pref:ProductVCode>
<pref:Producer> ... </pref:Producer>
</wb:Product>
<wb:Quantity>20.000</wb:Quantity>
<wb:Price>57.19</wb:Price>
<wb:Party>Партия №60074</wb:Party>
<wb:FARegId>000000000000</wb:FARegId>
<wb:InformF2> ... </wb:InformF2>
</wb:Position>
</wb:Content>
xml['wb:Content']['wb:Position']['wb:Identity']
xml['wb:Content']['wb:Position'][3]['wb:Identity']
Answer the question
In order to leave comments, you need to log in
Well, you can stupidly try and if an exception, then one element is nested. It's stupid, but if "on a one-time script" - it will probably go.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question