【发布时间】:2014-04-23 15:24:52
【问题描述】:
目前我正在通过以下方式将命名空间添加到文档中:
node.getOwnerDocument().getDocumentElement()
.setAttribute("xmlns:" + prefix, namespaceURI);
这个方法的问题是……
node.lookupPrefix(namespaceURI);
仍然返回null。
另一种尝试:
node.getOwnerDocument().getDocumentElement()
.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, prefix, namespaceURI);
最终导致:
org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.
有没有可行的方法?
【问题讨论】:
标签: java xml dom xml-namespaces