-3

How to parse an Xml which contains the field with an new line as it is using java parsers.

<ThreeDSecure>
   <acs_url>https://nithesh/testing</acs_url>
   <pareq_message>
    dfsgndfisfgsdgsdgsfggsfgsdfgs
    rfk/ffsgsdgfdssg32afaaaaffasa
    sgsdgsdfgsdfgfg
    ssdgfsgs342;dhhdgssssregs
    sffsgsdgfdssgsfregssdgsdg54df
    fdgdfgdfg
   </pareq_message>
</ThreeDSecure>

Here i need to read pareq_message tag value as it is, help me to resolve this. i have used the Xml parsers to read the fields, BUT i'm getting as an String with one line.

if("pareq_message".equals(sThreeDSecure)){
    String sPareqMessage =threeDSecureCursor.collectDescendantText();
    objNBGIBankResponseBean.setPareqMessage(sPareqMessage);
} //if closed (PareqMessage)
Nithesh
  • 31
  • 8
  • The XML parser may return just a single string, but that string is still multi-line, with embedded newlines. It may be your way of showing the string that ignores newlines. – Andreas Sep 19 '17 at 13:29
  • Yes GPI, im using StaxMate Parser – Nithesh Sep 19 '17 at 13:34
  • @forty-two you are right. I got confused. I will delete my comment so that future readers are not mislead. – GPI Sep 19 '17 at 13:41
  • @forty-two May i know alternate solution to get string as it is – Nithesh Sep 19 '17 at 13:45

1 Answers1

0

You can use LINQ to XML library to read the text with newline

XDocument xdoc = XDocument.Load("Data.xml");
var message = xdoc.Descendants("pareq_message").First();
var value = message.Value;

This should work.