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:
0042100323, LastName, FirstName, Middle, M
using something like:
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?
Use
characters
event to get text inside tag:UPDATE according to OP's comment:
to grab text selectively according to the containing tag; remember the last seen tag, and grab text only if the last seen tag is what you want.