标签:
var fs = require(‘fs‘);
var xpath = require(‘xpath‘);
var dom = require(‘xmldom‘).DOMParser;
// Read the file:
var data = fs.readFileSync(file, { encoding : ‘UTF-8‘ });
// Create an XMLDom Element:
var doc = new dom().parseFromString(data);
// Parse XML with XPath:
var childNodes = xpath.select(‘//path/to/node‘, doc);
标签:
原文地址:http://www.cnblogs.com/c-x-a/p/5481254.html