B
Brian Lonsdorf
Hi, i've got an xml file i'm parsing and creating objects from.
The xml is not named, nor formatted like my objects, so i need to define
a bunch of mappings/translations.
I'm looking for any design patterns or suggestions people might have to
elegantly solve this.
xml example:
<HotelDescriptiveContent CurrencyCode="USD" TimeZone="GMT;-06"
BrandCode="BV" HotelCode="517" HotelName="Americas Best Value Inn and
Suites - Downtown" Overwrite="true" UnitOfMeasureCode="1">
<HotelInfo WhenBuilt="2000" HotelStatus="Bookable" HotelStatusCode="1">
<CategoryCodes>
<LocationCategory Code="3"></LocationCategory>
<SegmentCategory Code="5"></SegmentCategory>
<HotelCategory Code="20"></HotelCategory>
</CategoryCodes>
<Description>All the comforts of home conveniently...</Description>
object example:
class Hotel
attr_accessor roperty_name, :brand
end
There's a bunch of other classes and corresponding awkwardly named tags.
It'd be killer if i could do a to_xml as well as from. But not
crucial...
Thanks for your help!
The xml is not named, nor formatted like my objects, so i need to define
a bunch of mappings/translations.
I'm looking for any design patterns or suggestions people might have to
elegantly solve this.
xml example:
<HotelDescriptiveContent CurrencyCode="USD" TimeZone="GMT;-06"
BrandCode="BV" HotelCode="517" HotelName="Americas Best Value Inn and
Suites - Downtown" Overwrite="true" UnitOfMeasureCode="1">
<HotelInfo WhenBuilt="2000" HotelStatus="Bookable" HotelStatusCode="1">
<CategoryCodes>
<LocationCategory Code="3"></LocationCategory>
<SegmentCategory Code="5"></SegmentCategory>
<HotelCategory Code="20"></HotelCategory>
</CategoryCodes>
<Description>All the comforts of home conveniently...</Description>
object example:
class Hotel
attr_accessor roperty_name, :brand
end
There's a bunch of other classes and corresponding awkwardly named tags.
It'd be killer if i could do a to_xml as well as from. But not
crucial...
Thanks for your help!