Ruby parsing xml file with nokogiri sax parser



I have done some reading and I have been trying to get certain data from a large XML file. The data looks like this:



<Provider ID="0042100323">
<Last_Name>LastName</Last_Name>
<First_Name>FirstName</First_Name>
<Mdl_Name>Middle</Mdl_Name>
<Gndr>M</Gndr>
</Provider>


I would like to write the start_element to add all of these to a record array like so


0042100323, LastName, FirstName, Middle, M



def start_element name, attributes = []
@@records << attributes[0][1] if name == "Provider"
end


How can I update my code to add the other tags to the array?


No comments:

Post a Comment