The length of childNodes XML : <blockquote>
  <p>I have 2 same together,First: </p>
</blockquote>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;body&gt;
    &lt;p id="demo"&gt;&lt;/p&gt;
    &lt;script&gt;
        var x, i, xmlDoc;
        var txt = "";
        var text = "&lt;book&gt;" + 
        "&lt;title&gt;Everyday Italian&lt;/title&gt;" +
        "&lt;author&gt;Giada De Laurentiis&lt;/author&gt;" +
        "&lt;year&gt;2005&lt;/year&gt;" +
        "&lt;/book&gt;";
        parser = new DOMParser();
        xmlDoc = parser.parseFromString(text,"text/xml");
        x = xmlDoc.documentElement.childNodes;
        document.write(x.length);
    &lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<blockquote>
  <p>Second File</p>
</blockquote>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
    &lt;meta charset="UTF-8"&gt;
    &lt;title&gt;DOM XML&lt;/title&gt;
    &lt;script language = "javascript" type = "text/javascript"&gt;
        xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function(){
            if(xhttp.readyState == 4 &amp;&amp; xhttp.status == 200){
                xmlDoc = xhttp.responseXML;
                x = xmlDoc.documentElement.childNodes;
                document.write(x.length);
            }   
        };
        xhttp.open('get','book3.xml',true);
        xhttp.send();
    &lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<blockquote>
  <p>and book3.xml file </p>
</blockquote>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;book&gt;
    &lt;title&gt;Everyday Italian&lt;/title&gt;
    &lt;author&gt;Giada De Laurentiis&lt;/author&gt;
    &lt;year&gt;2005&lt;/year&gt;
&lt;/book&gt;
</code></pre>

<p>I think text variable in the first code same with code in book3.xml, but when I print x.length, so the result in top is "3" and below in is "7". I try to many times but It's not change. Can you help me for the reason ???</p>
