node中XML格式转换成Json/String

(1)cnpm install fast-xml-parser --save
(2)在要用到的js文件中引入:const fxp = require(‘fast-xml-parser’);
(3)转成 json: const result = fxp.parse(xml_string);
(4) 转成String: JSON.stringify(result),

猜你喜欢

转载自blog.csdn.net/whiteBearClimb/article/details/107540642