diff --git a/nodes/core/locales/en-US/messages.json b/nodes/core/locales/en-US/messages.json index 0c4cb54be..f625794e1 100644 --- a/nodes/core/locales/en-US/messages.json +++ b/nodes/core/locales/en-US/messages.json @@ -531,7 +531,8 @@ }, "output": { "html": "the html content of the elements", - "text": "only the text content of the elements" + "text": "only the text content of the elements", + "attr": "an object of any attributes of the elements" }, "format": { "single": "as a single message containing an array", diff --git a/nodes/core/parsers/70-HTML.html b/nodes/core/parsers/70-HTML.html index 4451e2fa9..1d1c85aec 100644 --- a/nodes/core/parsers/70-HTML.html +++ b/nodes/core/parsers/70-HTML.html @@ -23,8 +23,8 @@ diff --git a/nodes/core/parsers/70-HTML.js b/nodes/core/parsers/70-HTML.js index a5088260b..30cf30f0c 100644 --- a/nodes/core/parsers/70-HTML.js +++ b/nodes/core/parsers/70-HTML.js @@ -32,9 +32,9 @@ module.exports = function(RED) { $(node.tag).each(function() { if (node.as === "multi") { var pay2 = null; - if (node.ret === "html") { pay2 = $(this).html(); } + if (node.ret === "html") { pay2 = cheerio.load($(this).html().trim()).xml(); } if (node.ret === "text") { pay2 = $(this).text(); } - //if (node.ret === "attr") { pay2 = $(this)[0]["attribs"]; } + if (node.ret === "attr") { pay2 = this.attribs; } //if (node.ret === "val") { pay2 = $(this).val(); } /* istanbul ignore else */ if (pay2) { @@ -43,9 +43,9 @@ module.exports = function(RED) { } } if (node.as === "single") { - if (node.ret === "html") { pay.push( $(this).html() ); } + if (node.ret === "html") { pay.push( cheerio.load($(this).html().trim()).xml() ); } if (node.ret === "text") { pay.push( $(this).text() ); } - //if (node.ret === "attr") { pay.push( $(this)[0]["attribs"] ); } + if (node.ret === "attr") { pay.push( this.attribs ); } //if (node.ret === "val") { pay.push( $(this).val() ); } } });