-1

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. 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 follows,

First Name - Rahul
Last Name - Sharma 
Suhaib Janjua
  • 3,538
  • 16
  • 59
  • 73
Vinod
  • 2,263
  • 9
  • 55
  • 104
  • There are many questions related to same in stackoverflow itself. And would you lets us know what you have tried till now. – Panther Apr 19 '15 at 07:38

1 Answers1

2

This might push to the right direction:

Which is the best library for XML parsing in java

And to capture the values in English, you would have to employ natural language processing to recognize which language the text you've captured using the xml parser. Luckily, you can use libraries for identifying english sentences. Here is a post outlining java libraries to identify the language of text:

How to detect language of user entered text?

Then after removing the text that is not english, you can go through in retrieving the dictionary.

Community
  • 1
  • 1
macmania314
  • 457
  • 2
  • 18