Python 2.5: ElementTree and UML in XML

前端 未结 2 628
我在风中等你
我在风中等你 2021-01-25 19:58

I\'m working with an XML file which represent an UML model. Here is an example of what it is:




        
相关标签:
2条回答
  • 2021-01-25 20:24

    see this page:http://effbot.org/zone/element-namespaces.htm

    ElementTree 1.3 (Python 2.7)

    ET.register_namespace(prefix, uri)

    ElementTree 1.2 (Python 2.5)

    ET._namespace_map[uri] = prefix

    0 讨论(0)
  • 2021-01-25 20:33

    register_namespace is only available since Python 2.7

    There might be another way to preserve namespaces with ElementTree in 2.5, but I'm not aware of it.

    Alternatively, you could try another parsing library. lxml preserves namespaces and its API is compatible with ElementTree.

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