вторник, 1 ноября 2011 г.

Few examples how to remove the ?xml version=\"1.0\" * encoding=\"UTF-8\"? from the input message

  /*
     * The following is to remove the <?xml version=\"1.0\"
     * encoding=\"UTF-8\"?> from the input message payload
     * sb - StringBuffer with input message payload
     */
  
  Newpayload = sb.toString();
    int len = Newpayload.indexOf(">");
    Newpayload = Newpayload.substring(len + 1);


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

    /*
     * The following is to remove the <?xml version=\"1.0\"
     * encoding=\"UTF-8\"?> from the RESULT_STRING
     */
RESULT_STRING = RESULT_STRING.replace('?','D');
RESULT_STRING = RESULT_STRING.replaceAll("<Dxml version=\"1.0\" encoding=\"UTF-8\"D>","");

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


      // convert InputStream to String
      byte[] bbuf = new byte[in.available()];
      int bblen = in.read(bbuf);

String inputConverted = new String(bbuf,"UTF-8");
inputConverted = inputConverted.replaceAll("<\\?xml version=\"1\\.0\" encoding=\"UTF-8\"\\?>","");

Комментариев нет:

Отправить комментарий