java parsing string in xml format

There are many ways to parse strings in xml format on the Internet, here is the one you use:


DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

DocumentBuilder builder = factory.newDocumentBuilder();  

Document doc = builder.parse(new InputSource(new StringReader(result)));//result is the xml string that needs to be parsed
 
NodeList nl = doc.getElementsByTagName("returnsms"); //Total nodes

String sendRes = doc.getElementsByTagName("returnstatus").item(0).getFirstChild().getNodeValue();//Get the value in the returnstatus node

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326607266&siteId=291194637