[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: xmlsimple: prevent folding multiple elements into array?

Brian Candler

7/17/2007 10:10:00 AM

> I have some xml that represents a somewhat weirdly formed hash.
> XmlSimple is eating some of my structure.

Try this:

xml = <<INPUT
<kern>
<map>
<key>
state
</key>
<string>
open
</string>
<key>
rate
</key>
<time>
daily
</time>
<key>
duration
</key>
<time>
monthly
</time>
</map>
</kern>
INPUT

# See http://www.germane-software.com/software/rexml/docs/tut...
require 'rexml/document'
doc = REXML::Document.new(xml)
doc.elements.each("/kern/map/*") do |element|
puts element.name, element.text.strip
end