如何从元素中删除名称空间
我正在使用 org.w3c.xml java 库 在执行一些任务时遇到一些困难:
- 我有一个 Element 对象;如何从它和前辈中删除命名空间?
如何创建没有命名空间的文档?我已经尝试过了
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); docBuilderFactory.setNamespaceAware(false); DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); 文档 doc = docBuilder.parse(new File("C:/Temp/XMLFiles/"+fileName+".xml"));
虽然看起来很有希望,但实际上并没有什么作用。我仍然收到带有命名空间的文档。
如何从元素创建文档?
文档 doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); doc.adoptNode(dataDefinition);
其中dataDefinition是一个元素,但是没有作用;我做错了什么?
I am working with org.w3c.xml java library
and encountering a few difficulties performing a few tasks:
- I have an Element object; how can I remove namespaces from it and the predecessors?
How can I create a Document without the namespaces? I have tried
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); docBuilderFactory.setNamespaceAware(false); DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); Document doc = docBuilder.parse (new File("C:/Temp/XMLFiles/"+fileName+".xml"));
Although it looks promising, it does not really work. I am still getting the doc with namespaces.
How do I create a document from an Element?
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); doc.adoptNode(dataDefinition);
where dataDefinition is an element, but it didn't work; what am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用以下 XSL 对其进行转换:
Try transforming it with the following XSL: