Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Special characters in XML structure when prepared using String

996913Oct 20 2013

Hi,

   I am preparing an XML structure using 'String'. I print the prepared XML structure in the server log. Issue is that I am seeing extra characters([[ and ]]) that I am not printing.

Please let me know how to get rid of those.

Code Excerpt

--------------------

        String xmlHeader = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";

        String lsb_xmlcon = xmlHeader;

        logger.info("ReqXMLString Process  1  --->" + lsb_xmlcon);

        lsb_xmlcon = lsb_xmlcon +("\n");

        logger.info("ReqXMLString Process  1.1  --->" + lsb_xmlcon);

        lsb_xmlcon = lsb_xmlcon +("<REQUEST>");

        lsb_xmlcon = lsb_xmlcon +("\n");

        logger.info("ReqXMLString Process  1.2  --->" + lsb_xmlcon);

Log

-----

ReqXMLString Process  1  ---><?xml version="1.0" encoding="utf-8" ?>

ReqXMLString Process  1.1  ---><?xml version="1.0" encoding="utf-8" ?>[[


]]

ReqXMLString Process  1.2  ---><?xml version="1.0" encoding="utf-8" ?>[[

<REQUEST>

]]

Thanks,

Message was edited by: 996913 This issue is observed only while running the code in server, not from Jdev. When we append the additional tags without new line character, "\n", there are no extra characters being added. Also, in other case also. where we used "Marshaller" to prepare the XML, we have seen this issue. After we set the below property to false, we got rid of the extra characters.                         jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false); Apparently the insertion of new line when the code runs on server(Weblogic 10.3.6.0) is creating the issue. Please let me know if anyone has come across a similar scenario. Thanks,

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 17 2013
Added on Oct 20 2013
0 comments
833 views