xml2js 怎么去除掉头部声明
发布于 8 年前 作者 LS666 5228 次浏览 来自 问答

项目需求在生成xml的时候不需要头部申明 <?xml version=“1.0” encoding=“UTF-8” standalone=“yes”?> 只需要这种格式 <xml>

</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 回复

headless选项

Options for the Builder class

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

回到顶部