hi ryan
i'm afraid you're going to kick yourself ;)
On 15 Dec 2004, at 05:45, Ryan Crumley wrote:
<snip>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^public class TestBetwixt { public static final void main(String args[]) throws Exception{ StringWriter out = new StringWriter(); out.write("<?xml version='1.0'?>");
BeanWriter writer = new BeanWriter(out); writer.setWriteEmptyElements( true );
PersonBean personBean = new PersonBean(); personBean.setName("ryan c"); personBean.setAge(24);
writer.write(personBean);
System.out.println("out: " + out);
StringReader xmlReader = new StringReader(out.toString());
BeanReader reader = new BeanReader();
reader.getXMLIntrospector().getConfiguration().setAttributesForPrimitiv es(true);
this line means that the writing is configured to write primitives as elements but the reading configuration is expecting them to be attributes.
a couple of related tips:
* using the same IntrospectionConfiguration instance for the reader and writer will ensure that the configurations are identical;
* XMLIntrospector caches the results of introspection (which takes quite a bit of time) and so as long as readers and writers share the same configuration, you'll get better performance if they share the same instance;
- robert
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
