Building XML with Nokogiri

Hi,

I'm trying to build XML using Nokogiri::XML::Builder, in the following
way:

builder = Nokogiri::XML::Builder.new do |xml|
xml.rpc {
  xml.get-chassis-inventory {

  }
}
end
puts builder.to_xml

But, the API seems to be having a problem with '-' in the
'get-chassis-inventory' tag. Any idea how to overcome this?

···

--
Posted via http://www.ruby-forum.com/.

The hyphen is being interpreted by Ruby as a minus operator. You can work around this by using send:

   xml.send(:"get-chassis-inventory") {
   }

···

On 10/03/2012 01:21 PM, ankit j. wrote:

Hi,

I'm trying to build XML using Nokogiri::XML::Builder, in the following
way:

builder = Nokogiri::XML::Builder.new do |xml|
xml.rpc {
   xml.get-chassis-inventory {

   }
}
end
puts builder.to_xml

But, the API seems to be having a problem with '-' in the
'get-chassis-inventory' tag. Any idea how to overcome this?

--
Lars Haugseth

Lars Haugseth wrote in post #1078521:

   xml.send(:"get-chassis-inventory") {
   }

Thank You!

···

--
Posted via http://www.ruby-forum.com/\.