Issue generating XML with hyphenated element names

Hello…

I’m trying to generate and XML file using .rxml and I’m having a
problem with element names that contain a hyphen. Here is a chunk of
the .rxml file:

xml.instruct! :xml, :version=>“1.0”
xml.properties do
@properties.each do |p|
xml.property do
xml.location do
xml.street-address(p.street_address)
xml.city-name(p.city)

end
end
end
end

As soon as the code hits the street-address line, a NoMethodError is
thrown:

undefined method `address’ for #<#Class:0x664ede8:0x664edc0>

Any idea how to fix this? The hyphens are dictated by the client,
thus I can’t change that.

Thanks,
Jeff

jjudge wrote:

xml.street-address(p.street_address)

x = Builder::XmlMarkup.new;nil
=> nil
x.tag!(‘a-b’)
=> “”

That’s in one of the Pragmatic books IIRC.


Phlip
"Pigleg too?", week 1

Thanks, that worked. To show the data within the element, use:

xml.tag!(“street-address”, p.street_address)