It wouldn't be very hard to update js4mirc to use the
v8 engine rather than spidermonkey (very old), which would allow you to make use of
commonJS implementations and libraries, including
jsdom, which would give you DOM-like access to an XML document. There are also http/net libraries to load that HTML into such a document. The embedding code is actually really simple:
http://bravenewmethod.wordpress.com/2011/03/30/embedding-v8-javascript-engine-and-go/