Re: getTextContent, JDK1.4

('binary' encoding is not supported, stored as-is)
You are dealing with an Element Node that has a text value.

 

The getNodeValue() method on this element returns null, as per
specification. However, the child Node of Element in question -- if there is
indeed text content -- is going to be a Text Node. The value of this Text
Node is what you are after.

 

To replicate getTextContent(), you need something like:

 

NodeList matchingNodes = document.getElementsByTagName(nodeName);
Node matchingNode = matchingNodes.item(whichOne); 

// The node we've found is an Element - get its child with text value
//
return matchingNode.getChildNodes().item(0).getNodeValue(); // of course,
you'd check if the child node is there indeed, and if it is text ...

 

hope this helps,

 

GW / http://eaiblueprint.com

 

 

Received on Sunday, 27 November 2005 01:41:41 UTC