This discussion is archived
0 Replies Latest reply: Oct 21, 2013 3:55 AM by 996913 RSS

Special characters in XML structure when prepared using String

996913 Newbie
Currently Being Moderated

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,

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points