With contents() and recursion I iterate over all elements of an element. If the actual element is a text node I want to get it’s text – but text() doesn’t give anything back.
markup += processXml($(this));
function processXml(element) {
if (element.nodeType == 3) {
return $(element).text() // that doesn't work !!
}
else {
var temp = "";
$(element).contents().each(function() {
temp += processXml(this);
});
return temp;
}
}
Use this instead…