commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brad Jones" <>
Subject Question on getting to the parsed XML
Date Tue, 02 Jul 2002 19:41:30 GMT

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:

			<field1>Value 1</field1>
			<field2>Value 2</field2>

Here's my digester code that I'm using to parse the XML show above:

TestPropertyBean tpbean = new TestPropertyBean(); fileInputStream = null;
Digester digester = new Digester();

//Adding data structure to digester to be parsed


//Rules for parsing the xml file.
digester.addBeanPropertySetter("toplevel/element/field1", "field1");
digester.addBeanPropertySetter("toplevel/element/field2", "field2");

	fileInputStream = new"c:/test.xml");
}catch( fnfe){
	//Handle exception for File Not Found

	Object data = digester.parse(fileInputStream);

}catch(org.xml.sax.SAXException se){
	//Handle exception for sax parser
}catch( 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.


Chat with friends online, try MSN Messenger:

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message