Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 65664 invoked from network); 2 Jul 2002 19:46:50 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 2 Jul 2002 19:46:50 -0000 Received: (qmail 15890 invoked by uid 97); 2 Jul 2002 19:47:01 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@jakarta.apache.org Received: (qmail 15874 invoked by uid 97); 2 Jul 2002 19:47:01 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 15862 invoked by uid 98); 2 Jul 2002 19:47:00 -0000 X-Antivirus: nagoya (v4198 created Apr 24 2002) X-Server-Uuid: 6E802067-ECFC-4FC2-A617-DD5220DD9CBB Message-ID: <7382FCA44E27D411BD4A00508BD68F95D5659D@pigeon.tumbleweed.com> From: "Martin Cooper" To: "'Jakarta Commons Developers List'" Subject: RE: Question on getting to the parsed XML Date: Tue, 2 Jul 2002 12:42:20 -0700 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) X-WSS-ID: 113CDC6E754676-01-01 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N This is a question for commons-user, not commons-dev. You're missing a call to addSetNext() or something similar in your rules (after the addBeanPropertySetter() calls). With your current code, the object is being created on the Digester stack, but dropped at the end of the parse. -- Martin Cooper > -----Original Message----- > From: Brad Jones [mailto:bostitch_21@hotmail.com] > Sent: Tuesday, July 02, 2002 12:42 PM > To: commons-dev@jakarta.apache.org > Subject: Question on getting to the parsed XML > > > > I am new to XML parsing (from an xml file to a Java object) > and I'm trying > out Digester. I'm having trouble figuring out how to use the > digester to > access the parsed XML once i've run the digester.parse() > method. FYI...The > following examples are just testing code for me to learn > digester so things > like Exception handling are not fully written. > > Here's a very simple xml file that I"m parsing: > > > > Value 1 > Value 2 > > > > Here's my digester code that I'm using to parse the XML show above: > > TestPropertyBean tpbean = new TestPropertyBean(); > java.io.FileInputStream fileInputStream = null; > Digester digester = new Digester(); > > //Adding data structure to digester to be parsed > digester.push(tpbean); > > digester.setValidating(false); > > //Rules for parsing the xml file. > digester.addObjectCreate("toplevel/element", > "com.ibm.us.force.bean.property.TestPropertyBean"); > digester.addBeanPropertySetter("toplevel/element/field1", "field1"); > digester.addBeanPropertySetter("toplevel/element/field2", "field2"); > > try{ > fileInputStream = new java.io.FileInputStream("c:/test.xml"); > }catch(java.io.FileNotFoundException fnfe){ > //Handle exception for File Not Found > } > > try{ > Object data = digester.parse(fileInputStream); > fileInputStream.close(); > > }catch(org.xml.sax.SAXException se){ > //Handle exception for sax parser > System.out.println(se.getMessage()); > }catch(java.io.IOException ie){ > //Hanlde exception for IO > } > > When the digester.parse() method is called, I can see the > TestPropertyBean > setters being called and the values being set to the bean > instance. My > problem is that I don't know how to get access to that data > once it's been > parsed...any suggestions would be greatly appreciated. > > Brad > > > _________________________________________________________________ > Chat with friends online, try MSN Messenger: http://messenger.msn.com > > > -- > To unsubscribe, e-mail: > > For additional commands, e-mail: > > > -- To unsubscribe, e-mail: For additional commands, e-mail: