Size limit for javascript [node]. NodeValue?

I get XML data through an AJAX call. One of the tags has a large amount of text, approximately 4000-5000 characters. In Firefox, the field is truncated around the 3000th character. Most of everything that I found on the Internet says that node sizes are not limited, but sometimes it depends on the implementation - there are no solid answers.

Does anyone have any suggestions as to why this could happen if there are no size restrictions on nodeValue? Any workarounds if so?

<test>
  <foo>very long string...</foo>
</test>

value = testTag.getElementsByTagName("foo").item(0).firstChild.nodeValue;

value truncated.

-If I print xmlHttp.responseText, all data will be printed.

+3
source share
4 answers

. :

" , , , , , node, . Opera 7-9.2x Mozilla/Netscape 6+, , . childNodes ."

+4

@Kooilnc , 4k Firefox.

, :

function getNodeText(xmlNode) {
    if(!xmlNode) return '';
    if(typeof(xmlNode.textContent) != "undefined") return xmlNode.textContent;
    return xmlNode.firstChild.nodeValue;
}

text = getNodeText(document.getElementsByTagName("div").item(0));
alert(text.length);

: http://jsfiddle.net/Bkemk/2/

: http://www.quirksmode.org/dom/tests/textnodesize.html

+1

node:

function getDataOfImmediateChild(parentTag, subTagName)
{
    var val = "";
    var listOfChildTextNodes;
    var directChildren = parentTag.childNodes;

    for (m=0; m < directChildren.length; m++)
    {
        if (directChildren[m].nodeName == subTagName)
        {
           /* Found the tag, extract its text value */
           listOfChildTextNodes = directChildren[m].childNodes;
           for (n=0; n < listOfChildTextNodes.length; n++)
           {
              if (typeof listOfChildTextNodes[n] == "TextNode")
                val += listOfChildTextNodes[n].nodeValue;
           }
         }
    }
    return val;

, , listOfChildTextNodes [n] TextNode.

0

@Ryley

, , , getElementsByTagName getElementsById , . :

<foo>
  <bar>
    <zoo>
       <bar>-</bar>
    </zoo>     
   <bar></bar>
</zoo>

fooTag.getElementsByTagName( "bar" ), s, ( ). , , " ", - .

0

Source: https://habr.com/ru/post/1779631/


All Articles