Here is another answer to this old question. Today I ran into a similar problem in my code, and I really read / write XML all the time. For some reason, I missed one important fact. If you want to use
NodeList elements = doc.getElementsByTagNameNS(namespace,elementName);
You need to parse your document with the factory, which will be used for names.
private static DocumentBuilderFactory getFactory() { if (factory == null){ factory = DocumentBuilderFactory .newInstance(); factory.setNamespaceAware(true); } return factory; }
source share