I'm serializing a variety of objects to XML. Most of them are custom java classes, but I also need to be able to serialize java wrapper types (ie: java.lang.String, java.lang.Float). Since castor treats them like simple types, I'm having trouble making unmarshalling work. The following code throws an exception when I deserialize:
String myString = "hello world"
StringWriter writer = new StringWriter(); Marshaller.marshal(myString, writer); String xml = writer.getBuffer().toString();
//The xml now looks like <?xml..... ?><string>hello world</string>
StringReader reader = new StringReader(xml);
Class theClass = Class.forName("java.lang.String");
String result = (String)Unmarshaller.unmarshal(theClass, reader);
I get the following exception: org.xml.sax.SAXException: Illegal Text data found as child of: string value: "hello world" What are my options for solving this problem?
Thanks in advance, Phill
----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
