Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lxml-element-maker

Build Coverage Version Python Version Python Version Licence

Requirements

  • python 3.4
  • lxml 3.4.4

Install

pip install lxml-element-maker

Usage

Transforms a python structure to an xml element with lxml :

from element_maker.utils import XMLElement

structure = {'ArchiveTransferRequest':
                      [
                          [
                              {'Comment': [
                                  ['baz'], {"foo": "bar"}
                              ]
                              },
                              {'Date': [
                                  ["2014-05-12T00:00:00Z"]
                              ]
                              }
                          ],
                          {"cars": "pizza"}
                      ]
                      }
namespace = "fr:gouv:culture:archivesdefrance:seda:v1.0"
xml_element = XMLElement(namespace=self.namespace, **self.structure)()
# Test the element with an xsd schema
result = xml_element.pass_xsd("./tests/data/test.xsd")
# Or test the element with an rng schema
result2 = xml_element.pass_rng("./tests/data/test.rng")

The result is an xml :

<ArchiveTransferRequest xmlns="fr:gouv:culture:archivesdefrance:seda:v1.0" cars="pizza">
    <Comment foo="bar">baz</Comment>
    <Date>2014-05-12T00:00:00Z</Date>
</ArchiveTransferRequest>

Authors

About

Transforms a python structure to an xml element with lxml

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.