Imagine this: You have a bunch of XML documents with similar information, but wildly different structure.
For example you want to check inventories of differing stores and one has its prices listed as a tag, the other as a property.
And also one calls its items "items" and the other calls them "products". Awful!
Now you could write 2 parser for each one and use the correct one for each type of document. But that sounds annoying.
flexparser lets you write one parser for all of your documents:
class StoreParser include Flexparser property 'store' do property %w[item product], collection: true do property 'name' property %w[price @price], transformation: :to_f # Parse either a tag or an attribute. end end end parsed = StoreParser.parse xml # You can now pass any of the two xml documents parsed.store.item.first.price #=> Float<10.5>
If you have a similar problem, come check it out!