1.拼接前的xml:
<?xml version="1.0" encoding="gbk"?>
<PayCheckInfo>
<HEAD>
<MSGCODE>NC_${dateTime?string("yyyyMMdd")}_${dateTime?string("HHmmss")}</MSGCODE>
<MSGID>TF2M_NC_IMPPAYRESULTORDER</MSGID>
<MSGNAME>申请单校验结果信息</MSGNAME>
<SOURCESYS>HB_I_M_D_TFM</SOURCESYS>
<TARGETSYS>HB_I_B_D_NC</TARGETSYS>
<CREATETIME>${dateTime?iso_nz("GMT+08")}</CREATETIME>
</HEAD>
<DATA>
<ROW ACTION="INSERT">
<Pk_>支付主键</Pk_>
<Result>校验结果</Result>
<Failinfo>校验失败信息</Failinfo>
<Bx>单据类型</Bx>
<Pk_children>子表主键</Pk_children>
</ROW>
</DATA>
</PayCheckInfo>
2.拼接后的:(原文中的双引号用单引号或用\转译)
return returnXml ="<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+
"<FEEDBACK>"+
"<HEAD>"+
"<MSGCODE>NC_TF2M_BXBILL_"+resultCode[0]+"</MSGCODE>"+
"<MSGID>NC_TF2M_BXBILL</MSGID>"+
"<MSGNAME>xxxx</MSGNAME>"+
"<SOURCESYS>HB_I_M_D_TFM</SOURCESYS>"+
"<TARGETSYS>HB_I_B_D_NC</TARGETSYS>"+
"<CREATETIME>"+resultCode[1]+"</CREATETIME>"+
"</HEAD>"+
"<DATA>"+
"<ROW ACTION='INSERT'>"+
"<RESULT>"+resultCode[2]+"</RESULT>"+
"<MSG></MSG>"+
"</ROW>"+
"</DATA>"+
"</FEEDBACK>";
第二种拼接方法:
StringBuffer resultBuffer = new StringBuffer();
resultBuffer.append(SendContanst.COMMON_XML_HEAD_6);
resultBuffer.append("<Data>");
resultBuffer.append("<ErrorCode>").append(errorCode).append("</ErrorCode>");
resultBuffer.append("<ErrorMsg>").append(errorMsg).append("</ErrorMsg>");
resultBuffer.append("<List>");
resultBuffer.append(buffer);
resultBuffer.append("</List>");
resultBuffer.append("</Data>");