The node value of a Document node is null. [1]
The text content of a Document node is the concatenation of the 
textContent value of every child node, excluding COMMENT_NODE and 
PROCESSING_INSTRUCTION_NODE nodes. [2]

[1] http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-1950641247
[2] http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-textContent

______________________________________
"You build world of steel and stone
I build worlds of words alone
Skilled tradespeople, long years taught:
You shape matter; I shape thought."
(http://www.songworm.com/lyrics/songworm-parody/ShapesofShadow.html)



From:
Thiwanka Somasiri <asthiwa...@gmail.com>
To:
j-users@xerces.apache.org
Date:
04/15/2011 01:34 PM
Subject:
Difference between Document.getNodeValue() and Document.getTextContent()?



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



Reply via email to