Java+DOM: How do I set the base namespace of an (already created) Document?
问题 I am dealing with an already created Document object. I have to be able to set it's base namespace (attribute name "xmlns") to certain value. My input is DOM and is something like: <root>...some content...</root> What I need is DOM which is something like: <root xmlns="myNamespace">...some content...</root> That's it. Easy, isn't it? Wrong! Not with DOM! I have tried the following: 1) Using doc.getDocumentElement().setAttribute("xmlns","myNamespace") I get a document with empty xmlns (it