I know how to parse an XML file that has one of each field e.g. Name, ID, Age by getting sub-elements using DOM parser and putting them into a Nodelist.
However I don't know how to parse and store data from an XML file with repeated fields. For example, each facility has more than one item, and it has more than one "link" with a distance to each link, for instance Seattle has a link to Fargo in this XML file, with a distance of 1426.
How would I approach parsing for the items and links? I can't simply match by the substring item, since I have multiple items.I don't know if it's appropriate to use a Nodelist, so I'm not sure which kind of data structure to use.
I've googled XML parsing in Java and I'm still confused, and I don't know what kind of data structure to use to store all this information.
<Facility>
<Name>Seattle, WA</Name>
<ProcessingRate>8</ProcessingRate>
<ProcessingCost>300</ProcessingCost>
<Link>
<Name>Fargo, ND</Name>
<Distance>1426</Distance>
</Link>
<Link>
<Name>San Francisco, CA</Name>
<Distance>808</Distance>
</Link>
<Item>
<Id>ABC123</Id>
<Quantity>45</Quantity>
</Item>
<Item>
<Id>JBL3100</Id>
<Quantity>52</Quantity>
</Item>
<Item>
<Id>PL132-C</Id>
<Quantity>54</Quantity>
</Item>
<Item>
<Id>PU238</Id>
<Quantity>60</Quantity>
</Item>
</Facility>
<Facility>