Parse XML and xmljava
1. parse the XML String of the String type to obtain the attribute value.
String resultXML = "<? Xml version = "1.0" encoding = "UTF-8"?>
<Result>
<Message value = "0"> yongyoulogin | ufida esb tester | creation | Failure | the specified person already exists. </message>
......
/Result> ";
(1) obtain the value of value in message
// Parse the XML string
StringReader sr = new StringReader (resultXML );
InputSource is = new InputSource (sr );
DocumentBuilderFactory factory = DocumentBuilderFactory. newInstance ();
DocumentBuilder builder = factory. newDocumentBuilder ();
Document doc = builder. parse (is );
Org. w3c. dom. Element root = doc. getDocumentElement ();
NodeList nl = root. getChildNodes ();
Node message = nl. item (0 );
String value = message. getAttributes (). getNamedItem ("value"). getNodeValue ();
(2) obtain the Intermediate Value of the tag.
String text = message. gettextcontent (); (text = "yongyoulogin | ufida esb tester | creation | failed | personnel already exists ,")