Question: I have html in the following format

```
<html>
    <body>
        <div>
            Hello
            <span>world1
            </span> 
            <span>world2
            </span> 
            <span>world3
            </span> 
        </div>
        <div>
            Hello
            <span>world1
            </span> 
            <span>world2
            </span> 
            <span>world3
            </span> 
        </div>
    </body>
</html>

```

I need to extract data from the div without including the text inside the span..and store it in a variable and extract the text inside the third span inside each div in another variable.
ie. in the first variable I need Hello.
And in the second variable I need world3.
How to do that .
The nodeValue property of each div returns text including that inside spans .How to avoid that

Answer: 
iterate over the `childNodes` of the div and build a string from the nodeValues of all childNodes that are textNodes(they have a `nodeType` of `3`)
I think you are looking for something like this. [fiddle](http://jsfiddle.net/jpuZJ/)

```
document.getElementsByTagName("div")[0].childNodes[0].textContent;
document.getElementsByTagName("div")[0].childNodes[5].textContent;

```