My code finishes like this:
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
Source sourceContent = soapResponse.getSOAPPart().getContent();
System.out.print("\nResponse SOAP Message = ");
StreamResult result = new StreamResult(System.out);
transformer.transform(sourceContent, result);
and it has this output in console(result is in ONE OUTPUT line but I will copy paste it like pretty xml just to be more clear).
<?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" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<VerifyEmailResponse xmlns="http://ws.cdyne.com/">
<VerifyEmailResult>
<ResponseText>Mail Server will accept email</ResponseText>
<ResponseCode>3</ResponseCode>
<LastMailServer>gmail-smtp-in.l.google.com</LastMailServer>
<GoodEmail>true</GoodEmail>
</VerifyEmailResult>
</VerifyEmailResponse>
</soap:Body>
</soap:Envelope>
So this works completly OK.Now if I want to have just ResponseText or ResponseCode value and to put those in some fields how can I process this result to XML and how to get that XML element?
Also I looked this question Convert StreamResult to string or xml but I do not see relation to my our question since I already have in my class code from the ANSWER but I am not able to process RESULT (to have it as XML which I can process additionally) if I add just
StringWriter writer = new StringWriter();
String resultString2=writer.toString();
I do not have reference to my RESULT variable which already has output.
I tried this also:
result.getOutputStream().toString();
but result is
java.io.PrintStream@3b9a45b3
result.toString();
does not give me desired result either
How to get this output to XML element from which I can retrieve and get specific XML element?
Thank you in advance,