在 Angular2 项目中,我有一个 xml 文件,其中包含有关一名员工的所有信息。我需要从 xml
文件中读取员工数据并显示在我的组件模板中。
如何使用http服务读取xml数据?
最佳答案
对于解析,您可以尝试使用 xml2js:https://github.com/Leonidas-from-XIV/node-xml2js .
检查这个其他答案: XML data parsing in angular 2
简而言之:
import { parseString } from 'xml2js';
/* ... */
let xml = "<root>Hello xml2js!</root>"
parseString(xml, function (err, result) {
console.dir(result);
});
关于angular - 在angular2中读取xml文件数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42577492/