Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python
ANN: XML builder for Python
 

Index | Next | Previous | View Flat


jonas at codeazur

Jul 2, 2008, 5:16 PM


Views: 132
Permalink
ANN: XML builder for Python

Not sure if it's been done before, but still...

from __future__ import with_statement
from xmlbuilder import builder, element

xml = builder(version="1.0", encoding="utf-8")
with xml.feed(xmlns='http://www.w3.org/2005/Atom'):
xml.title('Example Feed')
xml.link(None, href='http://example.org/')
xml.updated('2003-12-13T18:30:02Z')
with xml.author:
xml.name('John Doe')
xml.id('urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6')
with xml.entry:
xml.title('Atom-Powered Robots Run Amok')
xml.link(None, href='http://example.org/2003/12/13/atom03')
xml.id('urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a')
xml.updated('2003-12-13T18:30:02Z')
xml.summary('Some text.')
print xml

Will produce:

<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Example Feed</title>
<link href="http://example.org/" />
<updated>2003-12-13T18:30:02Z</updated>
<author>
<name>John Doe</name>
</author>
<id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>
<entry>
<title>Atom-Powered Robots Run Amok</title>
<link href="http://example.org/2003/12/13/atom03" />
<id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
<updated>2003-12-13T18:30:02Z</updated>
<summary>Some text.</summary>
</entry>
</feed>

http://github.com/galvez/gae-rest/tree/258066f5e1a32c999e04a9313943fdfa8e64edd9/xmlbuilder.py

--Jonas Galvez
--
http://mail.python.org/mailman/listinfo/python-list

Subject User Time
ANN: XML builder for Python jonas at codeazur Jul 2, 2008, 5:16 PM
    Re: ANN: XML builder for Python stefan_ml at behnel Jul 2, 2008, 9:59 PM
        Re: ANN: XML builder for Python stefan_ml at behnel Jul 2, 2008, 10:02 PM
            Re: ANN: XML builder for Python walter at livinglogic Jul 3, 2008, 4:37 AM
                Re: ANN: XML builder for Python jonas at codeazur Jul 3, 2008, 8:12 AM
    Re: ANN: XML builder for Python grflanagan at gmail Jul 3, 2008, 12:29 AM
        Re: ANN: XML builder for Python stefan_ml at behnel Jul 3, 2008, 6:32 AM
    Re: ANN: XML builder for Python stefan_ml at behnel Jul 3, 2008, 12:04 PM
        Re: ANN: XML builder for Python jonas at codeazur Jul 3, 2008, 1:49 PM
        Re: ANN: XML builder for Python walter at livinglogic Jul 3, 2008, 2:46 PM
            Re: ANN: XML builder for Python jonas at codeazur Jul 3, 2008, 7:30 PM
    Re: ANN: XML builder for Python walter at livinglogic Jul 3, 2008, 2:48 PM

  Index | Next | Previous | View Flat
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.