Using DOMParser in a function node?

I'm trying to use the xpath module in a function node by adding it into the function node setup. So far so good, the main issue I'm running into is how to parse the html string output from a HTTP request for use with the xpath module.

My understanding is the function setup is equivalent to xpath = require('xpath') and so I can't get dom = require('xmldom').DOMParser this way?

Or is there a better way of using xpaths in Node-Red? I know there are css selectors however I am using body text as part of the xpath so it's not useful in this case.

According to that packages readme, you also need to install the xmldom package. Then you will be able to get access as const dom = xmldom.DOMParser.

:man_facepalming: Ha, of course! Well that was obvious, couldn't see the forest through the trees yesterday for some reason. Thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.