martinblech / xmltodict

Python module that makes working with XML feel like you are working with JSON
MIT License
5.49k stars 462 forks source link

Add more namespace attribute tests #270

Closed leogregianin closed 2 years ago

leogregianin commented 3 years ago

Added tests with namespace attributes like this:

<root xmlns="http://defaultns.com/" 
      xmlns:a="http://a.com/"
      xmlns:b="http://b.com/"
      version="1.00">
   <x a:attr="val">1</x>
   <a:y>2</a:y>
   <b:z>3</b:z>
</root>

or

<root xmlns="http://www.url" version="1.00">
    <proc xmlns="http://www.url">
        (...)
javadev commented 2 years ago

It may be converted to this json

{
  "root": {
    "-xmlns": "http://defaultns.com/",
    "-xmlns:a": "http://a.com/",
    "-xmlns:b": "http://b.com/",
    "-version": "1.00",
    "x": {
      "-a:attr": "val",
      "#text": "1"
    },
    "a:y": "2",
    "b:z": "3"
  },
  "#omit-xml-declaration": "yes"
}
martinblech commented 2 years ago

Thanks!