Ruby XML::Builder with hyphen in Element name

builder, ruby, xml

Solution

xml.tag! 'latest-id', "latest ID with hiphen." 

Problem

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 ```

Original source