[英]XML behaviour changes from Android 2.3 to 4.1?
I want to ask if anyone knows, if something changed with the behaviour of org.w3c from Android 2.3 to 4.1 我想问问是否有人知道org.w3c的行为是否从Android 2.3更改为4.1
I have an XML Node : 我有一个XML节点:
<block nr="1" canceled="FALSE" lesson="TRUE">
<subject change="FALSE">AS</subject>
<room change="FALSE">1234</room>
<person change="FALSE">Name</person>
</block>
I give these node as Element
into a function where i wanna get attribute values 我将这些节点作为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();
}
On my device (Samsung Galaxy S Advance with Android 2.3) toReturn contains the same element as pElement, so I can return the attribute value. 在我的设备(带有Android 2.3的Samsung Galaxy S Advance)上,toReturn包含与pElement相同的元素,因此我可以返回属性值。
But on another device (Galaxy S2 with Android 4.1) I got null
with (Element)pElement.getElementsByTagName(pTag).item(0)
但是在另一台设备(带有Android 4.1的Galaxy S2)上,我的(Element)pElement.getElementsByTagName(pTag).item(0)
null
Did anyone have an idea why? 有人知道为什么吗?
Looks like a bug fix between the two Android versions. 看起来像是两个Android版本之间的错误修复。 element.getElementsByTagName should only include the elements descendants, not itself. element.getElementsByTagName应该仅包括元素后代,而不是其本身。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.