I am currently developing a parser that reads xml and returns specific values into documents. I have a strange bit of XML that I am not sure how to deal with. Here is an example:
<record>
<field name="Agreement_Role:addonSection.effectiveStartTime">15/08/2014</field>
<field name="Agreement_Role:addonSection.effectiveEndTime">31/12/9999</field>
<field name="Agreement_Role:addonSection.addonProduct">Gen</field>
<field name="Agreement_Role:addonSection.addonType">ProtectPlus</field>
<field name="Agreement_Role:addonSection.premium">21.70</field>
<field name="Agreement_Role:addonSection.displayOrder">2</field>
<field name="Agreement_Role:addonSection.replaceAddonType">ProtectPlus</field>
<field name="Agreement_Role:addonSection.addonCode">ProtectPlus</field>
<field name="Agreement_Role:addonSection.status">Live</field>
<field name="Agreement_Role:addonSection.cancellationRefund">00</field>
<field name="Agreement_Role:addonSection.effectiveStartTime">15/08/2014</field>
<field name="Agreement_Role:addonSection.effectiveEndTime">31/12/9999</field>
<field name="Agreement_Role:addonSection.addonProduct">Gen</field>
<field name="Agreement_Role:addonSection.addonType">Bd 1</field>
<field name="Agreement_Role:addonSection.premium">35.85</field>
<field name="Agreement_Role:addonSection.displayOrder">4</field>
<field name="Agreement_Role:addonSection.replaceAddonType">Breakdown</field>
<field name="Agreement_Role:addonSection.addonCode">Bd 1</field>
<field name="Agreement_Role:addonSection.status">Live</field>
<field name="Agreement_Role:addonSection.cancellationRefund">00</field>
<field name="acceptanceType">tacitCard</field>
<field name="Type">default</field>
<field name="effectiveDate">17/08/2014 00:00:00 BST</field>
<field name="expiryDate">16/08/2015 23:59:59 BST</field>
<field name="creationDate">15/08/2014 13:27:52 BST</field>
<field name="acceptanceDate">15/08/2014 13:43:27 BST</field>
#other elements follow this format
</record>
Contained in this sample are two add-ons. I would like to use the addonType field to specify if the add-on is present, and if so, display the related premium.
The add-ons are not separated into parent elements. The sample i have provided is everything I get. So how would I choose between the two premium elements of identical name and path?
If it helps, the elements would always be in the same order, but I would like to avoid using that incase it is changed in the future.
Thanks