Hi Kesh and Michael,

    Thanks for your reply. That worked for me. And also got to know that
another node is created for the "new line" which is there in the XML file as
follows:

        <note>
<to>Apache</to>
              ............................
   The "note" is the document element and its' node value is null. The next
node is a text node where its' node value is "\n". Next node is "to" and
its' node value is also null and so on.

Thanks.

On Fri, Apr 15, 2011 at 11:07 PM, Thiwanka Somasiri <asthiwa...@gmail.com>wrote:

> Hi all,
>
>     I wrote a sample program parse an XML file and tried to traverse
> through the DOM tree. I used Document.getNodeValue() method and
> Document.getTextContent() method to access the text values values of the
> nodes and getNodeValue() gave "null" values to the nodes, but
> getTextContent() gave correct values in the XML itself. Can someone explain
> me the difference between these two methods?
>
> This is the XML file I was using :
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <note>
> <to>Thiwanka</to>
>  <from>Erangi</from>
> </note>
>
> Thanks.
>
> --
>
> Regards
>
> A.S.Thiwanka Somasiri
>
> Skype : executionerwild
> MSN   : thi...@ymail.com
> <thi...@ymail.com>
>
>
>


-- 

Regards

A.S.Thiwanka Somasiri

Skype : executionerwild
MSN   : thi...@ymail.com
<thi...@ymail.com>

Reply via email to