0

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!

Fred_Alb
  • 174
  • 11
  • Possible duplicate of [Multiple XML Namespaces in tag with LXML](https://stackoverflow.com/questions/2850823/multiple-xml-namespaces-in-tag-with-lxml) – Maurice Meyer Apr 03 '18 at 06:54

1 Answers1

0

Found a solution that works for me.

Use the attrib attribute:

top.attrib["hello"] = "hi"

This will add that attribute to the element.

Fred_Alb
  • 174
  • 11