I have a project I'm working on where I request an XML document from a server and parse it to import the data into my system. I'm using Ruby 2.4.3.
My issues is that the XML comes in with element tags that have names starting with numbers. Nokogiri see these tags as part as the previous tag's content and messes up parsing the rest of the document.
I'm using Mechanize to request the data. Any ideas of which way to go?
The only thing I can think of is to write a completely custom parser in Mechanize which I would rather not do.
I was also thinking about parsing the xml as a string first to rename those elements, but wasn't sure if that was the cleanest way to do it. Any advice is much appreciated.
Here is an example of the data I'm parsing
<Rooms>\r
<2ndBedroomArea>144</2ndBedroomArea>\r
<2ndKitchenArea>144</2ndKitchenArea>\r
<3rdBedroomArea>168</3rdBedroomArea>\r
<4thBedroomArea>156</4thBedroomArea>\r
<FamilyRoomArea>368</FamilyRoomArea>\r
<FormalDiningRoomArea>144</FormalDiningRoomArea>\r
<GreatRoomArea>0</GreatRoomArea>\r
<InformalDiningRoomArea>187</InformalDiningRoomArea>\r
<KitchenArea>168</KitchenArea>\r
<LaundryRoomArea>84</LaundryRoomArea>\r
<LivingRoomArea>272</LivingRoomArea>\r
<MasterBedroomArea>238</MasterBedroomArea>\r
<OfficeArea>144</OfficeArea>\r
<RecreationRoomArea>0</RecreationRoomArea>\r
<2ndBedroomDim>12 x 12</2ndBedroomDim>\r
<2ndKitchenDim>12 x 12</2ndKitchenDim>\r
<3rdBedroomDim>12 x 14</3rdBedroomDim>\r
<4thBedroomDim>13 x 12</4thBedroomDim>\r
<FamilyRoomDim>16 x 23</FamilyRoomDim>\r
<FormalDiningRoomDim>12 x 12</FormalDiningRoomDim>\r
<GreatRoomDim>0 x 0</GreatRoomDim>\r
<InformalDiningRoomDim>17 x 11</InformalDiningRoomDim>\r
<KitchenDim>14 x 12</KitchenDim>\r
<LaundryRoomDim>6 x 14</LaundryRoomDim>\r
<LivingRoomDim>17 x 16</LivingRoomDim>\r
<MasterBedroomDim>17 x 14</MasterBedroomDim>\r
<OfficeDim>12 x 12</OfficeDim>
<RecreationRoomDim>0 x 0</RecreationRoomDim>\r
<2ndBedroomLen>12</2ndBedroomLen>\r
<2ndKitchenLen>12</2ndKitchenLen>\r
<3rdBedroomLen>12</3rdBedroomLen>\r
<4thBedroomLen>13</4thBedroomLen>\r
<FamilyRoomLen>16</FamilyRoomLen>\r
<FormalDiningRoomLen>12</FormalDiningRoomLen>\r
<GreatRoomLen>0</GreatRoomLen>\r
<InformalDiningRoomLen>17</InformalDiningRoomLen>\r
<KitchenLen>14</KitchenLen>\r
<LaundryRoomLen>6</LaundryRoomLen>\r
<LivingRoomLen>17</LivingRoomLen>\r
<MasterBedroomLen>17</MasterBedroomLen>\r
<OfficeLen>12</OfficeLen>\r
<RecreationRoomLen>0</RecreationRoomLen>\r
<2ndBedroomWid>12</2ndBedroomWid>\r
<2ndKitchenWid>12</2ndKitchenWid>\r
<3rdBedroomWid>14</3rdBedroomWid>\r
<4thBedroomWid>12</4thBedroomWid>\r
<FamilyRoomWid>23</FamilyRoomWid>\r
<FormalDiningRoomWid>12</FormalDiningRoomWid>\r
<GreatRoomWid>0</GreatRoomWid>\r
<InformalDiningRoomWid>11</InformalDiningRoomWid>\r
<KitchenWid>12</KitchenWid>\r
<LaundryRoomWid>14</LaundryRoomWid>\r
<LivingRoomWid>16</LivingRoomWid>\r
<MasterBedroomWid>14</MasterBedroomWid>\r
<OfficeWid>12</OfficeWid>\r
<RecreationRoomWid>0</RecreationRoomWid>\r
<5thBedroomArea>0</5thBedroomArea>\r
<5thBedroomDim>0 x 0</5thBedroomDim>\r
<5thBedroomLen>0</5thBedroomLen>\r
<5thBedroomWid>0</5thBedroomWid>\r
<6thBedroomArea>0</6thBedroomArea>\r
<6thBedroomDim>0 x 0</6thBedroomDim>\r
<6thBedroomLen>0</6thBedroomLen>\r
<6thBedroomWid>0</6thBedroomWid>\r
</Rooms>\r