commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gao Di <jaoy...@yahoo.com.cn>
Subject [Digester]what's the difference when parsing xml files like these?
Date Wed, 18 Aug 2004 08:28:16 GMT
i have the xml file as below:
<devices>
<device>
  <name>Gw1</name>
</device>
<device>
  <name>Gw2</name>
</device>
</devices>
then i can use digester to parse it with this class
it's aim it to put the <device> to a javabean and then
put all <deivce> to a arraylist.
List devices = new ArrayList();

public void parsedevice(){ 
Digester digester = new Digester();
digester.push(this);
digester.addCallMethod("devices/device", "addDevice",
1);
digester.addCallParam("devices/device/name", 0);
digester.parse(test.xml); 	

public void addDevice(String name, ){
Device device = new Device(name);
devices.add(device);
}

but after some consideration,i changed the xml file
like this:
<devices>
<device name='Gw1'/>
<device name='Gw2'/>
</devices>
then,the parse code doesn't work any more,anyone can
help me how to parse this kind of xml file?

_________________________________________________________
Do You Yahoo!?
150万曲MP3疯狂搜,带您闯入音乐殿堂
http://music.yisou.com/
美女明星应有尽有,搜遍美图、艳图和酷图
http://image.yisou.com
1G就是1000兆,雅虎电邮自助扩容!
http://cn.rd.yahoo.com/mail_cn/tag/1g/*http://cn.mail.yahoo.com/event/mail_1g/

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message