8000 GitHub - Pilfer/dict2xml: Really simple Python dictionary to XML converter.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Pilfer/dict2xml

8000

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

dict2xml

Really simple Python dictionary to XML converter. Put children as an object array or None inside the parent object - it'll call itself again and make it xml-y. There is no indent/pretty-print support because I hate XML and want it to die.

Example...

from dict2xml import dict2xml

if __name__ == "__main__":

  dictToConvert = {
      "tag" : "authentication",
      "attributes" : [
          {
              "name" : "realm",
              "value" : "some-realm-here"
          },
          {
              "name" : "role",
              "value" : "administrator"
          }
      ],
      "children" : [{
          "tag" : "credentials",
          "attributes" : [
              {
                  "name" : "username",
                  "value" : "pilfer"
              },
              {
                  "name" : "email",
                  "value" : "pilfer@git.hub"
              },
              {
                  "name" : "token",
                  "value" : "1337h4x4l1f3=="
              }
          ],
          "children" : None
      }]

  }

  d2x = dict2xml(False) #False for no debug, True for debug
  print d2x.genXML(dictToConvert) 
  # Output:
  # <authentication realm="some-realm-here" role="administrator"><credentials username="pilfer" email="pilfer@git.hub" token="1337h4x4l1f3=="></credentials></authentication>

About

Really simple Python dictionary to XML converter.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0