public static MapxmlToMap(HttpServletRequest request) throws IOException, DocumentException{ Map map = new HashMap (); SAXReader reader = new SAXReader(); InputStream ins = request.getInputStream(); Document doc = reader.read(ins); Element root = doc.getRootElement(); List list = root.elements(); for(Element e : list){ map.put(e.getName(), e.getText()); } ins.close(); return map; }
public static String textMessageToXml(TextMessage textMessage){ XStream xstream = new XStream(); xstream.alias("xml", textMessage.getClass()); return xstream.toXML(textMessage); }