From: NeilW Date: 2006-03-23T05:53:51+09:00 Subject: [ANN] XmlStruct-1.0.0 released XmlStruct ========= http://rubyforge.org/projects/xmlstruct/ Documentation ============= http://xmlstruct.rubyforge.org/ About ===== XML Markup the simple way. I've uploaded a small library to Rubyforge that allows you to markup data using XML tags using direct Ruby assignment following the example of OpenStruct. The library supports attributes and simple text elements - all of which are XML escaped before output. The interface is designed to be as simple as possible, with the least amount of syntactic sugar. The general idea is that you mark up your flat data and output a string containing the markup. The system works best when you have a small amount of data, and a large amount of irritating XML structure to impose upon it. The class came about to allow me to quickly draw up XML messages to send to the UK Government Gateway. Boy can you tell that that schema was designed by committee. I hope that it finds some use somewhere. Usage ===== I hope the interface is intuitive. Very simply you use assignment commands, e.g require 'rubygems' require 'xml_struct' @xmldoc = XmlStruct.new @xmldoc.GovTalkMessage={:xmlns => "http://www.govtalk.gov.uk/CM/envelope"} @xmldoc.GovTalkMessage.EnvelopeVersion="2.0" md=@xmldoc.GovTalkMessage.Header.MessageDetails md.Class="MAFF-IACS-AAPS2001" md.Qualifier="request" md.Function="submit" md.CorrelationID md.Transformation="XML" md.GatewayTimeStamp @xmldoc.GovTalkDetails.Keys.Key[0]={:Type => "VendorNumber"} @xmldoc.GovTalkDetails.Keys.Key[0]=275687 @xmldoc.GovTalkDetails.Keys.Key[1]={:Type => "MainCPH"} @xmldoc.GovTalkDetails.Keys.Key[1]="14/02/0327" @xmldoc.GovTalkDetails.Body print @xmldoc.to_s outputs 2.0
MAFF-IACS-AAPS2001 request submit XML
275687 14/02/0327 Enjoy === Neil Wilson, Aldur Systems Ltd