This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi, im using dom4j for creating a DOM and when im trying to do that
What gives me that code
What i want to..
It was working with old version of dom4j, i see that the problem is relying on putting a namespace as attribute, but i dont know how to do that, cause when i put to a namespace it's creating me with xmlns:xmlns="url"
Yes, that's right, the Java version is completely irrelevant.
You're using the wrong version of the createElement method. Since you're trying to create an element which is in a namespace, you should use the version which takes a QName rather than the version which takes a String. Be warned that since it's a default namespace, all of your elements in that example are in that namespace as well, so they should be created using a QName as well.
At least I think that's the case -- the API documentation which matias referred to has absolutely no text which explains anything. What a piece of junk.
Probably older versions of dom4j allowed you to cheat and insert namespace declarations as if they were attributes. They aren't attributes, so it looks like the newer versions have fixed that bug.