问题
When you have xml nodes with namespaces like:
<ns:abc>
then
getElementsByTagName("abc");
fails, but
getElementsByTagName("ns:abc");
works. But the issue is I don't know what is the namespace prefix chosen. Also for me,
getElementsByTagNameNS("*", "abc");
and
getElementsByTagNameNS("http://abcnamespace.com", "abc");
both return null.
If device is of interest, I am using CM7 on Nook. I don't want to use SAX, any other clean way to read the node lists.
回答1:
DocumentBuilderFactory.setNamespaceAware(true)
should fix your problem.
来源:https://stackoverflow.com/questions/7076149/android-xml-dom-parsing-when-you-have-namespaces