我想问是否有人知道,org.w3c 从 Android 2.3 到 4.1 的行为是否发生了变化
我有一个 XML 节点:
<block nr="1" canceled="FALSE" lesson="TRUE">
<subject change="FALSE">AS</subject>
<room change="FALSE">1234</room>
<person change="FALSE">Name</person>
</block>
我将这些节点作为Element
我想要获取属性值的函数
GetAttributeByTag(pNode, "block", "lesson");
private String GetAttributeByTag(Element pElement, String pTag, String pAttributeTag)
{
Element toReturn = (Element)pElement.getElementsByTagName(pTag).item(0);
return toReturn.getAttribute(pAttributeTag).trim();
}
在我的设备(带有 Android 2.3 的三星 Galaxy S Advance)上,toReturn 包含与 pElement 相同的元素,因此我可以返回属性值。
但在另一台设备(带有 Android 4.1 的 Galaxy S2)上,我得到null
了(Element)pElement.getElementsByTagName(pTag).item(0)
有人知道为什么吗?