JavaScript – getElementsByTagName causes NullPointerException
•
Android
Consider the following codes:
Ti.API.info(doc.getElementsByTagName('mytag'));
Ti.API.info(doc.getElementsByTagName('mytag').item(0));
XML is valid and consists of a valid element "mytag". The result of the first line is as expected:
[INFO] [...] [Ti.NodeList]
The second line throws a
Wrapping java.lang.nullpointerexception
This makes me confused because that line is good for IOS. Does anyone have an Iidea that may lead to errors?
resolvent:
I solved it with it
if (doc.getElementsByTagName("mytag").length>0) {..}
Thank you for your advice:)
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码