I am in a confusion that can you help me out this question i.e., I am directly reading xml message using xpath and reading values from it and also i am trying to convert xml to json and reading values because of light weight object so which one is best approach to read values. I am attaching following snippet code.
Below is the code to read values from xml
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document document = db.parse(source);
XPathFactory xpathFactory = XPathFactory.newInstance();
XPath xpath = xpathFactory.newXPath();
String eventNumber = xpath.evaluate("/event/eventnumber", document);
Below is to convert xml to json
JSONObject xmlJSONObj = XML.toJSONObject(xml1);