Android的XML DOM解析,当你有命名空间? [英] Android XML DOM Parsing when you have namespaces?

查看:235
本文介绍了Android的XML DOM解析,当你有命名空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当你有XML节点中包含的命名空间:

When you have xml nodes with namespaces like:

<ns:abc>

然后

getElementsByTagName("abc");

失败,但

getElementsByTagName("ns:abc");

工作。但问题是我不知道什么是选择的空间preFIX。而且对我来说,

works. But the issue is I don't know what is the namespace prefix chosen. Also for me,

getElementsByTagNameNS("*", "abc");

getElementsByTagNameNS("http://abcnamespace.com", "abc");

都返回空值。

both return null.

如果设备很感兴趣,我使用的角落CM7。我不希望使用SAX,任何其他清洁方式读取节点列表。

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.

推荐答案

DocumentBuilderFactory.setNamespaceAware(真)应该解决您的问题。

这篇关于Android的XML DOM解析,当你有命名空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆