Try the following...

// snip
Object obj =
 ((Element)root.selectSingleNode("/record/field")).getData();
 if (obj instanceof java.lang.String)
 { .... }
// snip


Florian Georg wrote:
Hi,

I wonder how to use the dom4j Schema capabilities to
get Java Objects mapped from XML elements like this :

<field name="foo" type="xsd:string">bar</field>

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)

help would be greatly appreciated !
 -- Florian

--

+------------------------------------------------------------+
| David Lucas mailto:[EMAIL PROTECTED] |
| Lucas Software Engineering, Inc. (740) 964-6248 Voice |
| Unix,Java,C++,CORBA,XML,EJB (614) 668-4020 Mobile |
| Middleware,Frameworks (888) 866-4728 Fax/Msg |
+------------------------------------------------------------+
| GPS Location: 40.0150 deg Lat, -82.6378 deg Long |
| IMHC: "Jesus Christ is the way, the truth, and the life." |
| IMHC: "I know where I am; I know where I'm going." <>< |
+------------------------------------------------------------+

Notes: PGP Key Block=http://www.lse.com/~ddlucas/pgpblock.txt
IMHO="in my humble opinion" IMHC="in my humble conviction"
All trademarks above are those of their respective owners.




-------------------------------------------------------
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

Reply via email to