I am trying to build a simple XML DOM in Java for Android. This works fine but the Android namespace prefix is always set to "ns0" but it should be "android"
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
doc = factory.newDocumentBuilder().newDocument();
doc.setXmlStandalone(true);
Element manifest = doc.createElement("manifest");
manifest.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:android",NS_ANDROID);
manifest.setAttributeNS(NS_ANDROID, "versionName", "bla");
doc.appendChild(manifest);
The output I get is the following:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ns0="http://schemas.android.com/apk/res/android" ns0:versionName="bla"/>
What do I need to change to get the following result:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionName="bla"/>