Jerremy Member
Posts : 2 Join date : 2011-06-21
| Subject: Empty XML and how to test for ? Thu Jun 23, 2011 8:25 am | |
| I have a slight issue. I am running thru some xml - if the first request does not contain the xml I need (getElementsByTagName) I go and request the next in line etc... I am having as issue because the first xml I request (the default one) exists, but it is empty and I am wasting a call to it which can sometimes take 1.5 - 2 seconds to get a response. I need to check for this, but is there a faster way to just see if the file is empty BEFORE I try to grab the elementsbytagname? I don't know, I am trying to speed it up any way I can.. I have this: - Code:
-
function getXML(n){ new Ajax.Request( xmlconfig.filesL[n], { method: 'get', contentType: "application/xml", onSuccess: function( transport ) { var itemTags = transport.responseXML.getElementsByTagName( 'item' ); if(itemTags.length == 0){ xmlCount++; if(xmlCount == xmlconfig.files.length){ DO SOME DOM BUILDING HERE }else{ getXML(xmlCount) // xml had no usuable data, request next in array. }
So, curious if there is a way to someone check to see if that file is empty before I request it or someway know its' empty and just dump it immediately? any advice appreciated. |
|
<HTML>LOL</HTML> Member
Posts : 8 Join date : 2011-03-09
| Subject: Re: Empty XML and how to test for ? Thu Jun 23, 2011 8:26 am | |
| If the XHR returns an empty file, then responseXML will be null, won't it? Or am I misreading this question? |
|