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:
https://github.com/apache/cxf/blob/cxf-2.1.9/rt/javascript/src/main/resources/org/apache/cxf/javascript/cxf-utils.js
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With