1

I am creating an XML file in python. The first element is built as follows:

xsi = "http://www.w3.org/2001/XMLSchema-instance"
mainElement = ET.Element("{" +xsi+ "}ArrayOfAnyType")

which results in a line:

<xsi:ArrayOfAnyType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

What I cannot solve is how to remove the xsi prefix in "xsi:Array...". The rest of the created xml file is just as I need.

Thanks for your hints

Piotr

4
  • you want a string like this: <ArrayOfAnyType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> ?
    – Shapi
    Dec 2, 2015 at 11:18
  • Exactly. That's how I want it.
    – Pioterski
    Dec 2, 2015 at 11:26
  • To add more information, I cannot use ET.tostring, so I cannot replace the prefix with empty string. I waas rather thinking of some solution within ET.Element creation.
    – Pioterski
    Dec 2, 2015 at 12:31
  • Try using XSLT, it is supported in lxml
    – har07
    Dec 2, 2015 at 12:59

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.