Android XML DOM Parsing when you have namespaces?

2020-07-27 05:32发布

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条回答
相关推荐>>
2楼-- · 2020-07-27 05:55

DocumentBuilderFactory.setNamespaceAware(true) should fix your problem.

查看更多
登录 后发表回答