首页 > 解决方案 > 我可以在 WSO2 ESB 6.5 的脚本中介中使用 appendChild 或其他函数吗?

问题描述

我正在尝试在 html 中构建有效负载以发送电子邮件。我正在使用脚本调解器,但如果条件为真,我想附加一个孩子。

<script language="js">
<![CDATA[var payload = <html>
            <div id="main">
                <div>
                    ......
                </div>
                <div>
                    .......
                </div>
            </div>
       </html>;
       
var child =  <div>
               ....
                </div>
if(true){
     payload.getElementById("main").appendChild(child);
}
        mc.setPayloadXML(payload);]]>
</script>

我曾尝试使用 appendChild(html 片段),但出现下一个错误:

引起:org.mozilla.javascript.EcmaError:TypeError:在对象中找不到函数getElementById

如何将孩子附加到 div?

谢谢

标签: javascripthtmlwso2esbenterprise-integration

解决方案


推荐阅读