如何实现像Hibernate一样通过配置文件读取XML文档中的数据
各位大哥大姐,小弟想解决个问题,希望大家不吝赐教。
现有如下一个XML文件:
test.xml
<A>
<B>test1</B>
<C>test2</C>
<D>
<E>test3</E>
<F>test4</F>
</D>
</A>
要求通过读取如下的形式的配置文件:
a.xml
<class name = "tes.A">
<property name="b" type="string"/>
<property name="c" type="string"/>
<property name="D" type="test.D"/>
</class>
d.xml
<class name = "tes.D">
<property name="e" type="string"/>
<property name="f" type="string"/>
</class>
如何将test.xml中的具体数据l映射到class数据对象中。?
package test;
class A{
private String b;
private String c;
private D d;
}
package test;
class D{
private String e;
private String f;
}