I'm trying to create a XML document using ElementTree. The document needs multiple namespaces, but I can't find any information in the documentation or online how to properly do this. I need the top row to have 3 namespaces, like so:
fu01:Page xmlns:xsi="website1" xmlns:fu01="website2" xsi:schemaLocation="website3">
Right now I've got:
top = ET.Element("fu01:Page")
top.set("xmlns:xsi", "website1")
Which prints out the first namespace, but I'm stuck as to how to get the other two in there as well.
Thanks in advance!
Found a solution that works for me.
Use the attrib
attribute:
top.attrib["hello"] = "hi"
This will add that attribute to the element.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.