I can't think of an existing rule that will help you. How's this?? (NB i have not tested but you should get the idea).
digester.addRule("class/student/attribute" new Rule() { private String fieldName; public void begin(Attributes atts) throws Exception { fieldName = atts.getValue("name"); } public void body(String text) throws Exception { Object o = getDigester().peek(); Field field = o.getClass().getField(fieldName); field.set(o, text); } } -----Original Message----- From: Manoj Chakkalakkal [mailto:[EMAIL PROTECTED] Sent: Tuesday, 26 April 2005 7:14 AM To: Jakarta Commons Users List Subject: RE: Digester beginner question Importance: Low I tried using the XPath notation as shown, but that does not work. Digester digester = new Digester(); digester.addObjectCreate("class", Student.class); digester.addBeanPropertySetter("class/student/[EMAIL PROTECTED]'id']", "id"); digester.addBeanPropertySetter("class/student/[EMAIL PROTECTED]'name']", "name"); But that does not seem to work. -----Original Message----- From: Manoj Chakkalakkal Sent: Monday, April 25, 2005 5:41 PM To: Jakarta Commons Users List Subject: Digester beginner question I have the following XML. <class> <student> <attribute name="id">10</attribute> <attribute name="name">Mark</attribute> </student> <student> <attribute name="id">11</attribute> <attribute name="name">Mary</attribute> </student> </class> public class Student{ String id; String name; } How do I write use Commons Digester to set the properties id and name of the class Student? I cannot change the structure of XML. Thank you -Manoj --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]