# \[ANN\] flexparser 1.0.3 - XML parser DSL with focus on data-normalization

**URL:** <https://rubytalk.org/t/ann-flexparser-1-0-3-xml-parser-dsl-with-focus-on-data-normalization/74525>\
**Category:** ruby-talk\
**Created:** [5 February 2018 07:37 UTC](https://rubytalk.org/t/ann-flexparser-1-0-3-xml-parser-dsl-with-focus-on-data-normalization/74525 "2018-02-05T07:37:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paul\_Martensen](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/paul_martensen/32/1908_2.png) [@Paul\_Martensen](https://rubytalk.org/u/Paul_Martensen)\
**Post date:** [5 February 2018 07:37 UTC](https://rubytalk.org/t/ann-flexparser-1-0-3-xml-parser-dsl-with-focus-on-data-normalization/74525/1 "2018-02-05T07:37:01Z")

</div>

Hi!

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:

```ruby
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!

Github: [https://github.com/lokalportal/flexparser](https://github.com/lokalportal/flexparser)  
Rubygems: [https://rubygems.org/gems/flexparser](https://rubygems.org/gems/flexparser)

Happy Coding!

Paul
