Here is the SOAP response:
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<SearchResponse xmlns="...">
<SearchResult>
<?xml version="1.0" standalone="yes"?> <items blahblahblah1 </items>
<?xml version="1.0" standalone="yes"?> <items blahblahblah2 </items>
</SearchResult>
</SearchResponse>
</soap12:Body>
</soap12:Envelope>
From within “SearchResult”, I want to get each of the full xmls of “items” one at a time. What I mean is, I want to get an entire “items blahblahblah /items”, individually. How do I do that?
Here is what I’ve figured out using DOM to get all of the xml from within “SearchResult”, but how do I get the items??
DocumentBuilder db = factory.newDocumentBuilder();
InputSource inStream = new InputSource();
inStream.setCharacterStream(new StringReader(soapResponse));
Document doc = db.parse(inStream);
NodeList nl = doc.getElementsByTagName("SearchResult");
xml = nl.item(0).getFirstChild().getNodeValue();
One approach would be to write a generic function to parse XML for a known tag.
{
You could then use this method to pull out search results i.e.
And use this result to parse items
Note that this method is not optimized in any way and though it should work for your purpose.