在用dom 创建xml 的元素时
Element element = dom.createElement("serviceTask");
element.setAttribute("custom:path","url1");
报出以下错误:ERROR: '没有说明名称空间前缀 'custom'。'
原因是在创建根元素,没有加入这个自定义的命名空间,需要在前面创建根元素时加入以下:
// 根元素
rootEle.setAttribute("xmlns:custom", "http://xx.cus.com");
rootEle.setAttribute("targetNamespace", "http://xx.cus.com");