我有一個Ruby類是這樣的:生成Ruby類XML與命名空間節點
class MyResponse
attr_accessor :results
def initialize(results = nil)
@results = results
end
end
有了這個代碼,
resp = MyResponse.new 'Response text'
qname = XSD::QName.new('http://www.w3schools.com/furniture', :MyResponse)
xml = XSD::Mapping.obj2xml(resp, qname)
puts xml
我設法生成該類這個XML:
<?xml version="1.0" encoding="utf-8" ?>
<n1:MyResponse xmlns:n1="http://www.w3schools.com/furniture">
<results>Response text</results>
</n1:MyResponse>
但我想<results>
節點也有像這樣的名稱空間前綴
我想弄清楚很長一段時間。請幫助我。
編輯:我只需要所有節點都有名稱空間前綴。我對任何其他方式或圖書館都是開放的。