Inserting the Line Breaks in the XML data dynamically
"<log date=\"" + date +
"\" trnType=\"" +
"\" accountType=\"" + XMLIllegalCharacterEncoder.encodedString(accountType) +
"\" ***accountId=\"" + accountBSB + "\r\n" + accountId*** +
"\" groupingID=\"" + groupingId +
"\"/>"
I am trying to insert an Line Break in the XML data which I am creating dynamically. I have tried few options, but nothing worked to insert the line break inside the XML data
In the Below piece of Code,
"\" ***accountId=\"" + accountBSB + "\r\n" + accountId*** +
Trying to insert an Break between accountBSB and accountI开发者_Go百科d
can any one help me the solutions with this
Instead of \r\n
, try
.
However, I would recommend against constructing XML using cut-n-paste techniques. Use a proper tool like JDOM or DOM4J (if you are using java)
UPDATE:
According to the XML specification, an attribute value must be "normalized" before it is passed to the application (http://www.w3.org/TR/REC-xml/#AVNormalize). Briefly, the normalization process replaces \r\n
sequneces with a single white space character. Any character reference, such as
is preserved. So, in your case, if you want an application consuming your XML to actually see the line break, you must use a character reference instead of literal carriage return and line feed.
精彩评论