NodeJS 读取XML文件

前端之家收集整理的这篇文章主要介绍了NodeJS 读取XML文件前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1、npm安装需要用的模块

npm install xpath.js

npm install xmldom

2、同步读取XML

var rf = require("fs"); var select = require("xpath.js"),dom = require("xmldom").DOMParser; function getApp(callback) { try { var data = rf.readFileSync("./App.xml","utf-8"); var doc = new dom().parseFromString(data); var nodes = select(doc,"//add"); } catch (e) { } } exports.getApp = getApp;

原文链接:https://www.f2er.com/xml/296231.html

猜你在找的XML相关文章