[XML-SIG] Python equivalent to Builder in Ruby?
Sébastien Arnaud
arnaudsj at gmail.com
Wed Apr 25 03:47:30 CEST 2007
Thank you Walter for the pointers. Both look kind of heavy weight but
I highly enjoyed discovering what they have to offer :)
Sébastien
On Apr 23, 2007, at 6:10 PM, Walter Dörwald wrote:
> Sébastien Arnaud wrote:
>
>> Hi,
>> 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:
>> http://builder.rubyforge.org/
>> 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.
>
> Python options would by XIST, Stan and probably a few others.
>
> Servus,
> Walter
>
>> TestBuilder.rb
>> ==============
>> require 'rubygems'
>> require 'builder'
>> xml = Builder::XmlMarkup.new(:target=>STDOUT, :indent=>2)
>> xml.instruct! :"xml-stylesheet", :type=>"text/xsl", :href=>"/xsl/
>> mytext.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") }
>> end
>> Output
>> ======
>> <?xml-stylesheet href="/xsl/mytext.xsl" type="text/xsl"?>
>> <mytestdoc>
>> <testing world="Escape me < > !!!">Hello World!</testing>
>> <person>
>> <comment>Jim's dog is nice & friendly</comment>
>> <name>Jim</name>
>> </person>
>> </mytestdoc>
>
More information about the XML-SIG
mailing list