小编毕兴涛*_*毕兴涛的帖子

使用 xml2js parseString 返回值

xml = `
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soap:Body>
      <GetCurrentRoomStatusGraphResponse xmlns="www.example.com">

         ...

         </GetCurrentRoomStatusGraphResult>
      </GetCurrentRoomStatusGraphResponse>
   </soap:Body>
</soap:Envelope>
`


var parseString = require('xml2js').parseString;
parseString(xml, function (err, result) {
    console.dir(result);
});
Run Code Online (Sandbox Code Playgroud)

我想要另一个函数使用这个值,如何返回这样的值?

parseString(xml, function (err, result) {
  return result
});
Run Code Online (Sandbox Code Playgroud)

javascript xml json node.js xml2js

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

javascript ×1

json ×1

node.js ×1

xml ×1

xml2js ×1