Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8548617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:32:14+00:00 2026-06-11T13:32:14+00:00

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

  • 0

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();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T13:32:14+00:00Added an answer on June 11, 2026 at 1:32 pm

    One approach would be to write a generic function to parse XML for a known tag.
    {

    public static String parseXMLForTag(String xml, String tag) {
            try {
                // Create XMLPullParserFactory & XMLPullParser
                XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
                XmlPullParser parser = factory.newPullParser();
                parser.setInput(new StringReader(xml));
    
                // boolean to indicate desired tag has been found
                boolean foundTag = false;
                // variable to fill contents
                StringBuilder tagContents = new StringBuilder();
    
                // loop over document
                int eventType = parser.getEventType();
                while (eventType != XmlPullParser.END_DOCUMENT) {
                    switch (eventType) {
                    case XmlPullParser.START_TAG:
                        if (parser.getName().equals(tag)) {
                            // Found tag, start appending to tagContents
                            foundTag = true;
                        } else if (foundTag) {
                            // New start tag inside desired tag
                            tagContents.append("<" + parser.getName() + ">");
                        }
                        break;
                    case XmlPullParser.END_TAG:
                        if (parser.getName().equals(tag)) {
                            // Finished gathering text for tag
                            return tagContents.toString();
                        } else if (foundTag) {
                            // end tag inside desired tag
                            tagContents.append("</" + parser.getName() + ">");
                        }
                        break;
                    case XmlPullParser.TEXT:
                        if (foundTag) {
                            // text inside desired tag
                            tagContents.append(parser.getText());
                        }
                        break;
                    }
                    // Get next event type
                    eventType = parser.next();
                }
                return null;
            } catch (Exception e) {
                return null;
            }
        }
    }
    

    You could then use this method to pull out search results i.e.

    String searchResult = parseXMLForTag(response, "SearchResult");
    

    And use this result to parse items

    String item = parseXMLForTag(searchResult, "item");
    

    Note that this method is not optimized in any way and though it should work for your purpose.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a XML Like this: <?xml version=1.0 encoding=utf-8?> <soap:Envelope xmlns:soap=http://www.w3.org/2003/05/soap-envelope xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:xsd=http://www.w3.org/2001/XMLSchema> <soap:Body>
Here is my XML response from an API: <?xml version=1.0 encoding=utf-8?> <soap:Envelope xmlns:soap=http://schemas.xmlsoap.org/soap/envelope/ xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance
Here is my response envelope: <s:Envelope xmlns:s=http://schemas.xmlsoap.org/soap/envelope/> <s:Body> <s:Fault> <faultcode>s:Client</faultcode> <faultstring xml:lang=en-US>The creator of
I am getting access denied when asking Magento with following request: <?xml version=1.0 encoding=UTF-8?>
I'm trying to assert SOAP response by using Xpath to select particular nodes, here
I have a relatively simple Soap response message XML which I'd like to modify
How should i parse SOAP response? Do i have to write LogicalHandler (like here
I want to convert a soap xml response and store it in a database.
OK n00b here with SOAP, Would like some clarification on how to use SOAP.
here is the wsdl soap field <element name=transactionCle nillable=true type=xsd:int/> when I call the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.