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;


你可能感兴趣的:(NodeJS)