I want to add xmlns:atom
to the root element of an XML file, the file already exists, I just want to modify it by adding the adding xmlns
. The rest of the files is to be left unchanged. As an example, I have <rss version="2.0">
in file and I want to convert it in to <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
using JDOM. How can I do this?
Asked
Active
Viewed 277 times
0

pnuts
- 58,317
- 11
- 87
- 139

Dipen Jogi
- 151
- 1
- 7
1 Answers
0
Once you have the input file loaded as a JDOM Document, you can:
document.getRootElement().addNamespaceDeclaration(
Namespace.getNamespace("atom", "..."));
Then, when you output the document it will have the additional namespace declaration.
Make sure you use the right URI for your Namespace... not '...' ...
See the documentation for addNamespaceDeclaration: