1、将字符串转换成XML Document
public static Map<String, String> getNameSpace() { //处理命名空间
Map<String, String> ns = new HashMap<String, String>();
ns.put(XMLConstants.XML_NS_PREFIX, XMLConstants.XML_NS_URI);
ns.put("s", "http://calculate.service.com");
return ns;
}
public Document loadXmlTemplete(String xmlContent) throws DocumentException, IOException {
DocumentFactory documentFactory = new DocumentFactory();
documentFactory.setXPathNamespaceURIs(getNameSpace());
SAXReader reader = new SAXReader();
reader.setDocumentFactory(documentFactory);
InputStream iStream = null;
try {
iStream = new ByteArrayInputStream(xmlContent.getBytes("UTF-8"));
} catch (UnsupportedEncodingException e) {
logger.error("不支持的字符编码类型!", e);
}
Document doc = n