0

I'm using lxml to write xml file. I try to write a root element like :

<Retour xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns="http://www.cnamts.fr/cereus/fichier/retour/v1"
    xsi:schemaLocation="http://www.cnamts.fr/cereus/fichier/retour/v1retour.xsd">

So I try :

NSMAP = {"xsi" : 'http://www.w3.org/2001/XMLSchema-instance'}
retour = ET.Element('Retour', nsmap = NSMAP)
retour.set('xmlns','http://www.cnamts.fr/cereus/fichier/retour/v1')

And I got :

<Retour xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.cnamts.fr/cereus/fichier/retour/v1">

But I don't find how to set xsi:schemaLocation="http://www.cnamts.fr/cereus/fichier/retour/v1retour.xsd"? With Element.set I have an unicode error.

mzjn
  • 48,958
  • 13
  • 128
  • 248

0 Answers0