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?
+6
A:
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.
bmargulies
2009-12-28 02:33:14
Do you have a list of broswers? Is there a way to check this constraint other then a broswer check?
Jeff Beck
2009-12-28 03:43:01
No. Any any browser can change at any time. The only safe thing to do us to run code that doesn't care.
bmargulies
2009-12-28 12:57:14
Oh well... what about that \pIE (8) accepts it all (length=25858)but Firefox doesn't...but IE doesn't accept w3School's new loadXMLDoc xhttp=new ActiveXObject("Microsoft.XMLHTTP")it worked with { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); }:(Never tought it could be a browser problem...Have you got something more specific (filename?) to look for in the Apache solution?thanks for the hints...
paul perrault
2009-12-28 14:21:01
Oh well... what about that [br]IE (8) accepts it all (length=25858) [br]but Firefox doesn't...[p]but IE doesn't accept w3School's new loadXMLDoc xhttp=new ActiveXObject("Microsoft.XMLHTTP"),[br]it worked with { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); }[br]:([br]Never tought it could be a browser problem...[br]Have you got something more specific (filename?) to look for in the Apache solution?[p]thanks for the hints...
paul perrault
2009-12-28 14:28:39
Great! Your solution works fine. Thanks. What about XMLDOM/XMLHTTP should we stick to XMLDOM?
paul perrault
2009-12-28 14:59:29
Please look at the entire source of js-utils.js from CXF, it addresses all of this.
bmargulies
2009-12-28 19:38:32
Sorry, the name is cxf-utils.js.
bmargulies
2009-12-28 19:39:13