CNode

xml2js 怎么去除掉头部声明

问答
LLS666发布于10 年前最后回复10 年前2 回复6665 浏览0 收藏

项目需求在生成xml的时候不需要头部申明 只需要这种格式

var body = {xml:{ appid: settings.wechat.AppID, mch_id: settings.wechat.MCH_ID, body:'Ipad mini 16G 白色', detail: 'detail', out_trade_no: WeChatPay.getOutTradeNo(), total_fee:1, nonce_str: WeChatPay.getNonceStr(), spbill_create_ip:utils.getClientIp(req), notify_url:settings.wechat.NORTIFYURL, trade_type: 'APP', }}; body.xml.sign = WeChatPay.random(body.xml); var xml = b.buildObject(body); console.log(xml); 这段代码生成的xml老是带着头 怎么去掉

查看回复

回复 (2)

C
coolicer#1·10 年前

headless选项

S
SinalVee#2·10 年前

Options for the Builder class

headless (default: false): omit the XML header. Added in 0.4.3.

参与回复
登录后即可参与回复。登录