[XML-SIG] Python equivalent to Builder in Ruby?
Walter Dörwald
walter at livinglogic.de
Tue Apr 24 01:10:28 CEST 2007
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