0

It's a really simple question but which I have no quick answer to it and I need help : I call a service that returns this XML body and need to parse it and get the element's values but for some reason I always get the values as null all the time. How can I parse this XML body via any recommended method in java ?

<?xml version="1.0" encoding="UTF-8"?>
<Response xmlns="http://tempuri.org/Response.xsd">
   <ResponseStatusDescription />
   <EntityPaymentReceiptNumber />
   <Description>Test</Description>
   <OperationName>CheckPayment</OperationName>
   <BankID>39</BankID>
   <EntityPaymentDate />
   <CheckPaymentID>188721103486</CheckPaymentID>
   <ResponseStatusCode>INFO2</ResponseStatusCode>
</Response>
Lakshan
  • 1,404
  • 3
  • 10
  • 23
  • Java has built-in XML Parsers... – OcelotcR Mar 19 '19 at 09:35
  • See [In Java, how do I parse XML as a String instead of a file?](https://stackoverflow.com/questions/562160/in-java-how-do-i-parse-xml-as-a-string-instead-of-a-file) to learn how to parse an XML string. – Jesper Mar 19 '19 at 10:50

1 Answers1

0

Generate a class from the xsd, i.e xjc http://tempuri.org/Response.xsd. Now, have your rest call expect Response as the return type.

sechanakira
  • 243
  • 3
  • 11