What's new? | Help | Directory | Sign in
Google
                
Show all Featured Wiki Pages:
Documentation
Feeds:
How to join?
Project owners:
  idmillington

This module allows you to mirror the structure of your target XML document in code, and have the corresponding XML generated for you. So you might write

>>> b = xml.book(xml.title("The Title"), xml.author("John Doe"))

and then get the xml with

>>> b.xml
'<book><title>The Title</title><author>John Doe</author></book>'

It was designed to be as simple as possible, and you can use it in this way, but there's sophsitication there too if you need it. You can work with namespaces and doctypes too, and target specific schemas if you need to:

>>> svg = XMLNamespace('svg', 'http://www.w3.org/2000/svg')
>>> makeXhtml(html.html(html.body(svg.svg(), class='main-page')))

produces

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:svg="http://www.w3.org/2000/svg">
<body class="main-page">
<svg:svg/>
</body>
</html>