Generate xml from ruby classes with namespaced nodes

emrehus

New Member
I have a ruby class like this:\[code\]class MyResponse attr_accessor :results def initialize(results = nil) @results = results endend\[/code\]With this code,\[code\]resp = MyResponse.new 'Response text'qname = XSD::QName.new('http://www.w3schools.com/furniture', :MyResponse)xml = XSD::Mapping.obj2xml(resp, qname)puts xml\[/code\]I managed to generate this xml from that class:\[code\]<?xml version="1.0" encoding="utf-8" ?><n1:MyResponse xmlns:n1="http://www.w3schools.com/furniture"> <results>Response text</results></n1:MyResponse>\[/code\]But I would like the \[code\]<results>\[/code\] node also to have the namespace prefix like \[code\]<n1:results>\[/code\]I am trying figure this out for a long time. Please help me out.
 
Back
Top