xerces-j-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Glavassevich <mrgla...@ca.ibm.com>
Subject Re: Difference between Document.getNodeValue() and Document.getTextContent()?
Date Fri, 15 Apr 2011 18:03:11 GMT
And if you want to retrieve the text node child of an element node you
should be traversing to it with getFirstChild() and the other navigation
methods.

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

keshlam@us.ibm.com wrote on 04/15/2011 01:41:19 PM:

> 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 <asthiwanka@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   : thiwas@ymail.com
Mime
View raw message