diff --git a/lib/node-htmlparser.js b/lib/node-htmlparser.js index ac3625d..21aba93 100644 --- a/lib/node-htmlparser.js +++ b/lib/node-htmlparser.js @@ -545,6 +545,9 @@ inherits(RssHandler, DefaultHandler); try { entry.pubDate = new Date(DomUtils.getElementsByTagName("updated", item.children, false)[0].children[0].data); } catch (ex) { } + try { + entry.content = DomUtils.outerHTML(DomUtils.getElementsByTagName("content", item.children, false)[0].children[0]); + } catch (ex) { } feed.items.push(entry); }); } @@ -799,6 +802,41 @@ function DefaultHandler (callback, options) { , getElementsByTagType: function DomUtils$getElementsByTagType (type, currentElement, recurse, limit) { return(DomUtils.getElements({ tag_type: type }, currentElement, recurse, limit)); } + + , outerHTML: function DomUtils$outerHTML(currentElement) { + var runningMarkup = ''; + + switch (currentElement.type) { + + case 'tag': + + if (currentElement.name == 'br') { + runningMarkup = runningMarkup + '
'; + } else { + runningMarkup = runningMarkup + '<' + currentElement.name; + if (currentElement.attribs) { + for (var key in currentElement.attribs) { + runningMarkup = runningMarkup + ' ' + key + '=' + '"' + currentElement.attribs[key] + '"'; + }; + } + runningMarkup = runningMarkup + '>'; + if (currentElement.children) { + currentElement.children.forEach(function(el) { + runningMarkup = runningMarkup + DomUtils.outerHTML(el); + }); + } + runningMarkup = runningMarkup + ''; + } + break; + + case 'text': + runningMarkup = runningMarkup + currentElement.data; + break; + + } + + return runningMarkup; + } } function inherits (ctor, superCtor) {