XStream

通过数据生成XML
	/**
	 * 通过数据生成XML
	 * @param subObj
	 * @return Object
	 */
	public static  Object  toXMLString(Object subObj ){
		XStream xStream = new XStream(new DomDriver());//不需要XPP3库 
		xStream.alias(subObj.getClass().getName(),subObj.getClass());
		String xml = xStream.toXML(subObj);
        return xml;
    
	}
通过XML生成表的数据	
	/**
	 * 通过XML生成表的数据	
	 * @param xmlString
	 * @return Object
	 */
	public static  Object  invokeXMLString(Object xmlString ){
		XStream xStream = new XStream(new DomDriver());//不需要XPP3库 
		return xStream.fromXML(xmlString.toString()); 
	}


你可能感兴趣的:(xml)