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

Pioterski
  • 11
  • 1
  • you want a string like this: `` ? – Shapi Dec 02 '15 at 11:18
  • Exactly. That's how I want it. – Pioterski Dec 02 '15 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 02 '15 at 12:31
  • Try [using XSLT](http://stackoverflow.com/questions/9816252/xslt-remove-namespace-prefix-from-elements), it is [supported in lxml](http://lxml.de/xpathxslt.html#xslt) – har07 Dec 02 '15 at 12:59

0 Answers0