xml parsing on first load

You must Login before you can answer or comment on any questions.

Hi,

I am facing very strange issue in parsing xml. XML parsing fails to parse the xml response on the first loading of application in the ipad simulator as well as device. If I completely quit the application and if reopen it, it works!!!!

On the very first load of application I am getting the following error in the Titanium Appcelerator.

[WARN] Exception in event callback. {
expressionBeginOffset = 6394;
expressionCaretOffset = 6430;
expressionEndOffset = 6435;
line = 135;
message = "Result of expression 'xmlDoc.getElementsByTagName(\"Count\")' [null] is not an object.";
name = TypeError;
sourceId = 200357448;
sourceURL = "file://localhost/Users/manaday.mavani/Library/Application%20Support/iPhone%20Simulator/4.2/Applications/572185D6-43A5-458F-8D47-B5EE0A6D3C41/IRApp.app/Helper/Helper.js";
}
[WARN] Exception in event callback. {
expressionBeginOffset = 10019;
expressionCaretOffset = 10058;
expressionEndOffset = 10063;
line = 211;
message = "Result of expression 'xmldoc.getElementsByTagName(\"Snapshot\")' [null] is not an object.";
name = TypeError;
sourceId = 200357448;
sourceURL = "file://localhost/Users/manaday.mavani/Library/Application%20Support/iPhone%20Simulator/4.2/Applications/572185D6-43A5-458F-8D47-B5EE0A6D3C41/IRApp.app/Helper/Helper.js";
}
after quitting and relaunching the app works perfectly.

Thanks in advance.

— asked 2 years ago by Manaday Mavani
2 Comments
  • If you also show us the code you're using to load and parse the XML in your app, it will be a bit more helpful for us to be able to help you out ;)

    — commented 2 years ago by Kosso .

  • Hi Kosso, Here I've shared the code http://pastie.org/1647446

    — commented 2 years ago by Manaday Mavani

1 Answer

the first thing I would do is call your handler on the onload event and not the onreadystatechange event, it is a common approach in most httpClient samples I have seen.

change this

snapshotxhr.onreadystatechange = handler;
to this
snapshotxhr.onload = handler;

— answered 2 years ago by Aaron Saunders
answer permalink
1 Comment
  • Hi Aaron, I already tried that one with no success. I want to make my question more clear that on the very first load of application (means when the application is just has been installed on the ipad and loaded in the simulator) this issue is being raised all the subsequent app load (unless i delete it from the simulator) dont reflects this issue and works fine with no change of code. Very very strange!!!

    — commented 2 years ago by Manaday Mavani

Your Answer

Think you can help? Login to answer this question!