'use of : in subElement on python
I hope you are doing well guys.
I am creating a XML file using python, I am not an expert, but so far I think I am doing fine. During the creation of a subelement I ran to the next issue.
I created a subelement named AP and then inside also I created the subelement named adr, inside Adr I need to create another subelement with the name of S, the complication came when I tried to add the attribute with :, as shown I need to create the next code with the structure "xsi:type", my code is as shown bellow:
AP= et.SubElement(root, 'AP')
adr= et.SubElement(AP, 'Adr')
et.SubElement(adr, 'S',type="num", **'xsi=:type=number').text = str(reles['num_exel'][0])
et.SubElement(adr, 'S',type="str", **'xsi=:type=street').text = str(reles['str_exel'][0])
the goal is to have something similar to the next XML structure
<Adr>
<S type="num" xsi:type="number">10</P>
<S type="str" xsi:type="street">linton</P>
</Adr>
I hope its clear, and I will appreciate your help Thanks a lot
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
