[XML-SIG] Python equivalent to Builder in Ruby?

Sébastien Arnaud arnaudsj at gmail.com
Mon Apr 23 23:54:44 CEST 2007


Just like any other dev on the block I took RoR for a test drive to  
see what the fuss was all about, but short of sharing my experience  
with it and what I liked or disliked about it, I wanted to know if  
there is a close equivalent to the RXML/Builder Ruby lib that saw the  
light under the RoR project:

To me it is the best part of the Rails framework :), but I can't seem  
to find a simple and syntactically attractive module in python that  
achieves the same purpose. I posted below a quick naive example for  
those who are not familiar with ruby-builder lib.

Thank you for any type of pointers! If I can't find anything then I  
might decide to start to write my own python based module on RXML/ 
Builder philosophy.



require 'rubygems'
require 'builder'

xml = Builder::XmlMarkup.new(:target=>STDOUT, :indent=>2)
xml.instruct! :"xml-stylesheet", :type=>"text/xsl", :href=>"/xsl/ 

xml.mytestdoc do
   xml.testing("Hello World!", :world=>"Escape me < > !!!")
   xml.person { |b| b.comment("Jim's dog is nice & friendly"); b.name 
("Jim") }

<?xml-stylesheet href="/xsl/mytext.xsl" type="text/xsl"?>
   <testing world="Escape me &lt; &gt; !!!">Hello World!</testing>
     <comment>Jim's dog is nice &amp; friendly</comment>

More information about the XML-SIG mailing list