Answer the question
In order to leave comments, you need to log in
How to parse \ parse XML of this kind?
Good day!
I'm asking for help in inventing the wheel.
There is an xml file of the format:
Broken with hyphens and trimmed the length of the line to improve readability. The original contains about 80k lines, 20 attributes each.
<xml>
<Detail_collection>
<Detail
Полное_и_сокращенное_наименование_организации="Общество с ограниченной ответственностью "РогаИКо" Сокращенно: ООО "РогаИКо""
ИНН_организации="0123456789"
КПП_организации="123456789"
Адрес__место_нахождения___организации="РОССИЯ,0123456,"Кукуево г,,Затерянная ул,15/7,,"
Адрес_электронной_почты_организации="[email protected]" />
<Detail Полное_и_сокращенное_наименование_организации="..".." />
<Detail Полное_и_сокращенное_наименование_организации="..".." />
</Detail_collection>
</xml>
<?xml version="1.0" encoding="utf-8" ?>
<xml>
<Detail_collection>
<Detail text1="sometext11" text2="sometext21" text3="sometext31" />
<Detail text1="sometext12" text2="sometext22" text3="sometext32" />
</Detail_collection>
</xml>
import xml.etree.cElementTree as ET
from SQL_worker import Write_to_SQL
tree = ET.parse("data.xml")
root = tree.getroot()
for data in root.findall(".//Detail"):
a = (data.attrib["text1"])
b = (data.attrib["text2"])
c = (data.attrib["text3"])
Write_to_SQL(a, b, c)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question