I would like to use Ruby and REXML to wrap an XML document and allow
access to the element nodes, attributes, and text.  Essentially I need
an XML document builder loosely coupled from the document.

It seems like Ruby is powerful enough to code generate a class given an
XML document or build an object at run-time with the appropriate
accessors.

For instance:

order = XmlBuilder.new

order.add("root").add("header")
order.root.add("body")

order.body.add("component").attributes["type"] = "metric"

order.write($stdout)

I'd also like to be able to plug-in input validation when assigning
values to elements and attributes.

Has anyone done this before?

Thanks.

-- 
Posted via http://www.ruby-forum.com/.