是否可以使用node.js加载XML / HTML文档并执行getElementsByTagName等操作?
Node.js默认情况下不提供DOM,但是有一个很棒的模块可以提供适当的HTML DOM:https://github.com/tmpvar/jsdom。
var cheerio = require('cheerio'),
$ = cheerio.load('<h2 class="title">Hello world</h2>');
$('h2.title').text('Hello there!');
$('h2').addClass('welcome');
$.html();
//=> <h2 class="title welcome">Hello there!</h2>