I'm looking for fastets way to stripe HTML tags from content in Google Apps Script.
For now I'm using these functions to HTML parsing:
function getTextFromHtml(body) {
return getTextFromNode(Xml.parse(body, true).getElement());
}
function getTextFromNode(x) {
switch(x.toString()) {
case 'XmlText': return x.toXmlString();
case 'XmlElement': return x.getNodes().map(getTextFromNode).join('');
default: return '';
}
}
But for long HTML's this way is so inefficient.
Sample HTML content: http://pastebin.com/FmB4hvN2
Any ideas?