How is it that I always get only the first 4096 chars of a valid XML text node? (using JavaScript...) is a text node limited?
Yes. Some browsers limit to 4096, and split longer texts into multiple text node children of the parent element. If you look at the source to Apache CXF you will find some utility Java script to deal with this, if no place else.
// Firefox splits large text regions into multiple Text objects (4096 chars in
// each). Glue it back together.
function getNodeText(node) {
var r = "";
for (var x = 0;x < node.childNodes.length; x++) {
r = r + node.childNodes[x].nodeValue;
}
return r;
}
Also see:
for more goodies in this neighborhood.
by the way, you can use normalize method to join all contiguous TextNode into one instead of looping them to obtain the text.
来源:https://stackoverflow.com/questions/1967741/is-there-a-4096-character-limit-for-javascript-xml-text-nodes