0

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.

Tim
  • 28,212
  • 8
  • 63
  • 76
  • 1
    Unless this is pseudocode, it'd be *really helpful* if you tagged your question with the language you're using. Looks like C# but I could be wrong. – Tim Jun 26 '17 at 18:37
  • I am using Java. Sorry for not adding that. Even if you guys can help me with pseudocode, it would help. – malvarn123 Jun 26 '17 at 19:43
  • This should help you out: https://stackoverflow.com/questions/2591098/how-to-parse-json-in-java – Evan Weissburg Jun 27 '17 at 00:59

0 Answers0