nodejs xpath

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);

posted @ 2016-05-11 11:24  公众号python学习开发  阅读(915)  评论(0编辑  收藏  举报