1.测试实体类
package test;
@SuppressWarnings("serial")
public class Policy implements java.io.Serializable{
private String LicenseNo;
private String LicenseType;
private String ComCode;
private String InsuredName;
private long IdentifyNumber;
public Policy() {
super();
}
public String getLicenseNo() {
return LicenseNo;
}
public void setLicenseNo(String licenseNo) {
LicenseNo = licenseNo;
}
public String getLicenseType() {
return LicenseType;
}
public void setLicenseType(String licenseType) {
LicenseType = licenseType;
}
public String getComCode() {
return ComCode;
}
public void setComCode(String comCode) {
ComCode = comCode;
}
public String getInsuredName() {
return InsuredName;
}
public void setInsuredName(String insuredName) {
InsuredName = insuredName;
}
public long getIdentifyNumber() {
return IdentifyNumber;
}
public void setIdentifyNumber(long identifyNumber) {
IdentifyNumber = identifyNumber;
}
}
2.转换工具类
package test;
import java.io.ByteArrayInputStream;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
* XML工具类
* @author suyunlong
*
*/
public class XmlUtil {
/**
* 解析XML转换为Object
* @param strXML xml字符串
* @param elementName 解析根标签名
* @param className 类名全路径(包名+类名)
* @return
*/
public static List<Object> parseObject(String strXML,String