This is what I'm trying to do:
xml = Nokogiri::XML::Builder.new do |x|
x.root do
x.book do
x.attribute('isbn', 12345) # Doesn't work!
x.text("Don Quixot")
end
end
end.doc
I know that I can do x.book(isbn: 12345), but this is not what I want. I want to add an attribute within the do/end block. Is it at all possible?
The XML expected:
<root>
<book isbn="12345">Don Quixot</book>
</root>