Multiple XML Namespaces in tag with LXML

后端 未结 1 1422
自闭症患者
自闭症患者 2021-02-13 05:01

I am trying to use Pythons LXML library to create a GPX file that can be read by Garmin\'s Mapsource Product. The header on their GPX files looks like this



        
1条回答
  •  暖寄归人
    2021-02-13 05:45

    The problem is with your attribute name.

    attrib={"{xsi}schemaLocation" : schemaLocation},
    

    puts schemaLocation in the xsi namespace.

    I think you meant

    attrib={"{" + xsi + "}schemaLocation" : schemaLocation}
    

    to use the URL for xsi. This matches your uses of namespace variables in the element name. It puts the attribute in the http://www.w3.org/2001/XMLSchema-instance namespace

    That gives the result of

    
    
    

    0 讨论(0)
提交回复
热议问题