Ruby XML::Builder with hyphen in Element name
Question
I'm trying to generate some XML using XML::Builder, but my element names need to have hyphens in it.
When I try I get undefined methods, with the element name being truncated at the hyphen
xml.instruct!
xml.update-manifest do
xml.latest-id @latest_version_update.guid
xml.download-url @latest_version_update.download_url
xml.release-information-url version_guid_url(@latest_vesrion_update.guid)
end
The fixed version is
xml.instruct!
xml.tag! 'update-manifest' do
xml.tag! 'latest-id', @latest_version_update.guid
xml.tag! 'download-url', @latest_version_update.download_url
xml.tag! 'release-information-url', version_guid_url(@latest_vesrion_update.guid)
end
Solution
xml.tag! 'latest-id', "latest ID with hiphen."
OTHER TIPS
I have tried to fix dash or hiphen in xml to do this.
xml.send("latest-id") "latest ID With hiphen"
For more reference to go this link xml with hiphen
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow