RubyForge: XML::Simple (with my experiences as updates)

RubyForge: XmlSimple: Project Info

Rather short after discovering this module, I made use of it with my FRITZ!Box call monitor in order to read my Google Contacts as XML. With this approach, that was a rather easy piece of cake.

Update 2011-03-29:
If an element has not attributes, the (text) content of that element simply gets appended as string to the list at the hash field by the name of that element.
Now if the element has attributes, the (text) content goes together with the attributes to a hash list, that gets appended to that list instead. The (text) content actually goes into a hash field by the name of “content“.
Example:

text -> “e”=>[            “text”]text -> “e”=>[{“content”=>”text”,”a”=>”v”}]

My Ruby code operates like this:

x.instance_of?(Hash) ? x[‘content’] : x


Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.