Android 版本低于 2.2 的 org.w3c.dom.Node

2024-01-03

getTextContent() 不是可识别的函数。 getNodeValue() 对于字符串工作得很好,但是每当我尝试使用 getNodeValue() 解析数字时,它都会返回 null!

如何使用此类从 XML 解析 Long?


造成这种情况的根本原因在于getTextContent()方法是 W3C DOM Level 3 方法;看到changes http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/changes.htmlDOM level 3 核心规范的部分。

Node 接口有两个新属性:Node.baseURI 和 Node.textContent。 ...

and getTextContent()是新属性的 getter。

(据推测,旧版本的 Android 不实现 DOM 级别 3 API。)

的行为getTextContent()一般情况下有点复杂;请参阅规格文本上下文属性 http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#Node3-textContent。在目标节点是具有(仅)文本内容的元素的简单情况下,node.getTextContext()是相同的node.getFirstChild().getNodeValue().

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Android 版本低于 2.2 的 org.w3c.dom.Node 的相关文章

随机推荐