Returns the Documentbuilderfactory object
Documentbuilderfactory factory = Documentbuilderfactory.newinstance ();
Get returned Documentbuildr object with Documentbuilderfatory object
Documentbuilder builder = Factory.newdocumentbuilder ();
Get a DOM and return it to the Document object
Document document = Builder.parse (IS);
Get a elment root element
Element element = Document.getdocumentelement ();
NodeList thenodelist = Element.getelementsbytagname ("Selectsysresult");
System.out.println ("SSS:" +thenode.item (0). Getnodename ());
System.out.println ("SSSs:" +thenode.item (0). Gettextcontent ());
Traverse these child nodes
/*for (int i = 0; i < childnodes1.getlength (); i++) {
System.out.println ("Sub-node One layer:" +i);
Get the node for each corresponding position I
Node Node1 = Childnodes1.item (i);
if ("Soap:body". Equals (Node1.getnodename ())) {
NodeList childNodes2 = Node1.getchildnodes ();
for (int j = 0; J < Childnodes2.getlength (); j + +) {
System.out.println ("Sub-node Layer two:" +j);
Node Node2 = Childnodes2.item (j);
if ("Selectsysresponse". Equals (Node2.getnodename ())) {
NodeList ChildNodes3 = Node2.getchildnodes ();
for (int k = 0; k < childnodes3.getlength (); k++) {
System.out.println ("Sub-node layer three:" +k);
Node Node3 = Childnodes3.item (k);
if ("Selectsysresult". Equals (Node3.getnodename ())) {
SYSTEM.OUT.PRINTLN ("Success");
System.out.println (Node3.gettextcontent ());
}
}
}
}
}
}*/
String jsontext = Thenodelist.item (0). Gettextcontent ();
Jsontext = jsontext.substring (Jsontext.indexof ("["), Jsontext.lastindexof ("]") +1);
Jsonarray Jsonarr = Jsonarray.fromobject (Jsontext);
String sysidarr[] = new string[jsonarr.size ()];
for (int i = 0; i < jsonarr.size (); i++) {
If
Sysidarr[i] = Jsonarr.getjsonobject (i). getString ("_sysid");
System.out.println (Sysidarr[i]);
}
Processing of Java JSON data