Forum Stats

  • 3,733,360 Users
  • 2,246,748 Discussions


Special characters in XML structure when prepared using String


   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;"ReqXMLString Process  1  --->" + lsb_xmlcon);

        lsb_xmlcon = lsb_xmlcon +("\n");"ReqXMLString Process  1.1  --->" + lsb_xmlcon);

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

        lsb_xmlcon = lsb_xmlcon +("\n");"ReqXMLString Process  1.2  --->" + lsb_xmlcon);



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" ?>[[




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 is creating the issue. Please let me know if anyone has come across a similar scenario. Thanks,

This discussion has been closed.