Michael Champion mike.champion at softwareag-usa.com
Thu Dec 30 15:54:04 GMT 1999

----- Original Message -----
From: "Lucio Piccoli" <Lucio.Piccoli at one2one.co.uk>
To: <xml-dev at ic.ac.uk>
Sent: Thursday, December 30, 1999 9:23 AM
Subject: Element_node.getValue()

> hi all,
> I am getting very frustreated with the sun XML java parser. I am using the
> DOM. When i retrieve a ELEMENT_NODE, i call getValue() on the node and it
> returns null. Yet when i call toString() i get all the data.
> The element is defined as
> <!ELEMENT body (PCDATA) >
> How do i get the value from the element?

Blame the DOM working group (to which I must confess membership), not Sun.
The value() of an Element is always null according to the DOM spec.  The
standard way to get the value of an element is to get the child Text node
and get its value.  Most DOM implementations have some sort of convenience
method to get the text value of a single element ... but sometimes you have
to get the text of the entire subtree under the element (which is apparently
what Sun's toString() method is doing).

In the DOM WG's defense, it is *exactly* this reason for making the value()
of an Element null -- Should it return the value of the entire subtree?
Should the text come back with markup embedded or not?  There was no
consensus as to the best way to do it, so we essentially punted.

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To unsubscribe, mailto:majordomo at ic.ac.uk the following message;
unsubscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)

More information about the Xml-dev mailing list