Skip to content
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
44 lines (34 sloc) 756 Bytes

Pydicttoxml

Convert python dictionary into a xml equivalent output

Usage of Pydicttoxml

d = {
  'student': {
      'name': 'Shera',
      'age': 25,
      'address': {
          'pin': 500082,
          'city': 'Hyderabad',
          'state': 'telangana',
          'country': 'India'
      }
   }
}

from pydicttoxml import dict2xml
xml = dict2xml(d, root_tag_name="data")

Output

<?xml version="1.0" encoding="UTF-8"?>
<data>
  <student>
    <name>Shera</name>
    <age>25</age>
    <address>
      <pin>500082</pin>
      <city>Hyderabad</city>
      <state>telangana</state>
      <country>India</country>
    </address>
  </student>
</data>
You can’t perform that action at this time.