genetate:
Document document = DocumentHelper.createDocument(); Element rootElement = document.addElement("contactdata-migration-request"); //rootElement.addAttribute("id", String.valueOf(requestId)); Element emailElement = rootElement.addElement("email"); emailElement.setText(email); String str = document.asXML();
parse:
SAXReader saxReader = new SAXReader(); Document document; StringReader strReader = new StringReader(contactXml); document = saxReader.read(strReader); Node responseIdNode = document.selectSingleNode("/contactdata-migration-response/@id");
Document document = DocumentHelper.createDocument(); Element rootElement = document.addElement("contactdata-migration-request"); //rootElement.addAttribute("id", String.valueOf(requestId)); Element emailElement = rootElement.addElement("email"); emailElement.setText(email); String str = document.asXML();
parse:
SAXReader saxReader = new SAXReader(); Document document; StringReader strReader = new StringReader(contactXml); document = saxReader.read(strReader); Node responseIdNode = document.selectSingleNode("/contactdata-migration-response/@id");
有疑问加站长微信联系(非本文作者)