Easy A
Would you like to react to this message? Create an account in a few clicks or log in to continue.


 
HomeHome  Latest imagesLatest images  SearchSearch  RegisterRegister  Log inLog in  

Share
 

 Empty XML and how to test for ?

View previous topic View next topic Go down 
AuthorMessage
Jerremy
Member
Member
Jerremy

Posts : 2
Join date : 2011-06-21

Empty XML and how to test for ? Empty
PostSubject: Empty XML and how to test for ?   Empty XML and how to test for ? EmptyThu 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.
Back to top Go down
<HTML>LOL</HTML>
Member
Member
avatar

Posts : 8
Join date : 2011-03-09

Empty XML and how to test for ? Empty
PostSubject: Re: Empty XML and how to test for ?   Empty XML and how to test for ? EmptyThu 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?
Back to top Go down
 

Empty XML and how to test for ?

View previous topic View next topic Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Easy A :: Empty XML and how to test for ? Edit-trash Useless :: Trash-