You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 24, 2021. It is now read-only.
I ran into a problem parsing xhtml in atom feeds.
If a feed contains xhtml, the parsing doesn't work as expected.
It returns "[object object]" for the tag instead of the actual content.
So here is my helper function that solved the problem for me.
var getHTMLData = function(tag) {
if (typeof(tag) === "string") {
return tag;
}
var content = "<" + tag.name;
var children = tag.children || [];
if (tag.attributes) {
for (var attr in tag.attributes) {
if (tag.name === "a" && attr === "href") {
content += " " + attr + "='" + tag.attributes[attr] + "' target='_blank'";
}
content += " " + attr + "='" + tag.attributes[attr] + "'";
}
}
if (tag.isSelfClosing) {
content += "/>";
} else {
content += ">";
}
for (var i = 0, l = children.length; i < l; i++) {
var _tag = children[i];
content += getHTMLData(_tag);
}
content += "</" + tag.name + ">";
return content;
}
I call it in the child_by_name function
for (var i = 0, l = children.length; i < l; i++) {
if (children[i].name === name) {
if (children[i].attributes.type === "xhtml") {
var _children = children[i].children || [];
for (var j = 0, k = _children.length; j < k; j++) {
_children[j] = getHTMLData(_children[j]);
}
}
return children[i];
}
}
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I ran into a problem parsing xhtml in atom feeds.
If a feed contains xhtml, the parsing doesn't work as expected.
It returns "[object object]" for the tag instead of the actual content.
So here is my helper function that solved the problem for me.
I call it in the child_by_name function
The text was updated successfully, but these errors were encountered: