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 8613631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:55:35+00:00 2026-06-12T04:55:35+00:00

I get a SOAP message from a web service, and I can convert the

  • 0

I get a SOAP message from a web service, and I can convert the response string to an XML file using the below code. This works fine. But my requirement is not to write the SOAP message to a file. I just need to keep this XML document object in memory, and extract some elements to be used in further processing. However, if I just try to access the document object below, it comes as empty.

Can somebody please tell me how I can convert a String to an in-memory XML object (without having to write to a file)?

String xmlString = new String(data); 
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();  

DocumentBuilder builder;  
try  
{  
    builder = factory.newDocumentBuilder();  

    // Use String reader  
    Document document = builder.parse( new InputSource(  
            new StringReader( xmlString ) ) );  

    TransformerFactory tranFactory = TransformerFactory.newInstance();  
    Transformer aTransformer = tranFactory.newTransformer();  
    Source src = new DOMSource( document );  

    Result dest = new StreamResult( new File( "xmlFileName.xml" ) );  
    aTransformer.transform( src, dest );

}
  • 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-12T04:55:37+00:00Added an answer on June 12, 2026 at 4:55 am

    Remove the 5 last lines of code, and you’ll just have the DOM document in memory. Store this document in some field, rather than in a local variable.

    If that isn’t sufficient, then please explain, with code, what you mean with “if I just try to access the document object below, it comes as empty”.

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

Sidebar

Related Questions

I have to use several SOAP messages to get data from a web service.
I am getting a response in form of a SOAP message from a web
(Following up on this question: Getting raw XML response from Java web service client
I have a response from web service in SOAP envelope as follows: <s:Envelope xmlns:s=http://schemas.xmlsoap.org/soap/envelope/>
I have worked in a SOAP message to get the LoginToken from a Webservice,
I'm having a problem with getting a simple output from a web service using
I am sending a SOAP message from a webservice client (code was generated by
I need to get the SOAP message from exchange object I receive in my
How can I call methods from sharepoint fast search web service ex: QueryEx ,
So I've been working on fetching data from a web service and using it

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.