XML Parsing in java to get it in Key, Value Pair?



There are many XML Parsing technique are there which I am not aware yet. I want to parse the xml (Form Data) and get the form output data in Key, Value pair. So Any one suggest me which xml parsing technique makes it easy to get the values in key value pair for the following xml format,



<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<control for="9bd2f8fd2421eb0b0a410feaa1f482c50551486a" name="first-name" type="input" datatype="string">
<resources lang="en">
<label>First Name</label>
<help />
<hint>Your first or given name
</hint>
<alert />
</resources>
<resources lang="fr">
<label>Prénom</label>
<help />
<hint>
Votre prénom
</hint>
<alert />
</resources>
<value>Rahul</value>
</control>
<control for="8532f26e19a5b33200f56bb839c5f3aa2fa3a25f" name="last-name" type="input" datatype="string">
<resources lang="en">
<label>Last Name</label>
<help />
<hint>Your last name</hint>
<alert />
</resources>
<resources lang="fr">
<label>Nom de famille</label>
<help />
<hint>Votre nom de famille</hint>
<alert />
</resources>
<value>Sharma
</value>
</control>
</metadata>


Note I need to capture only values with English Language. For the above xml I need the output as folloes,



First Name - Rahul
Last Name - Sharma


Any suggestion please..


No comments:

Post a Comment