Can you operate on XML / HTML documents in node.js?

Problem

Is it possible to load an XML / HTML document with node.js and perform operations such as getElementsByTagName ?

Problem courtesy of: lostsource

Solution

node.js doesn’t give you a DOM “out of the box”, but there is a great module that provides a proper HTML DOM: https://github.com/tmpvar/jsdom.


Edit: there are also several modules that help with interacting with XML. Here’s a list of them on the wiki (this page is deprecated): https://github.com/joyent/node/wiki/modules#wiki-parsers-xml

Solution courtesy of: jmar777

View additional discussion.