> From the cookbook-example I got the impression that receiving
> a java.lang.String object is quite that simple :
>
> // snip
> Object obj =
> ((DatatypeElement)root.selectSingleNode("/record/field")).getValue();
> if (obj instanceof java.lang.String)
> { .... }
> // snip
>
> but it's not that simple, is it ? :)
> (I just got an ClassCastException from DefaultElement to DatatypeElement)
>
Hi Georges,
Your problem is not an XML but a JAVA problem ;-)
The getValue method returns a String object and
since your DatatypeElement class is not a sublass of String it will
never be possible to cast a String to a DatatypeElement.
Since the getValue() returns a String (that is what you are looking
for anyway) you do not need to cast and you do not
even need to test the class type :
// Get the string value of the node
String value = root.selectSingleNode("/record/field")).getValue();
Thierry
-------------------------------------------------------
This sf.net email is sponsored by: To learn the basics of securing
your web site with SSL, click here to get a FREE TRIAL of a Thawte
Server Certificate: http://www.gothawte.com/rd524.html
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user