I have a xml file for Person A, and I need to parse through it and take out the characteristics of the person by using JSon Parsers and JSon Arrays. The xml file looks like:
<PersonA>
<Physique
Eyes = "Brown"
Hair = "Black"
Height = "5 10'"
/>
<Identification
Name = "Bob"
Ethnicity = "Asian"
/>
</PersonA>
I have something like this written until now, but am not sure if it is the correct way to tackle this problem.
public JSONObject paserWSDLXML(String wsdlXML)
{
String jsonString = "";
JSONObject wsdlDefination = new JSONObject();
try
{
JSONParser parser = new JSONParser();
String outPutJSONString = XML.toJSONObject(wsdlXML).toString();
wsdlDefination = (JSONObject)parser.parse(outPutJSONString);
}
catch(Exception e)
{
e.printStackTrace();
}
return wsdlDefination;
}
How would you guys take on this problem? I am new to JSon so any sort of help would be useful.
Thank You.