sequential analyzing of several xml files?

sequential analyzing of several xml files?

Hi experts,

I am trying to use get jquery get method to read and analyze a number of xml files.

I am scanning a folder for xml files, storing the urls (using the file protocol notation) in an array of variable length - which means that the script cannot tell in advance how many files must be interpreted.

It looks like...

  1.  <script type="text/javascript">
  2.   var myXMLfilenames = new Array();
      var myXMLentries = new Array();
      var indexofentries = 0;



  3. // scanning part cut out - result is something like...
  4.   myXMLfilenames[0] =  "file:///c:/bla/notesfromadmin.xml";
  5.   myXMLfilenames[1] = "file:///c:/bla/notesfromhall01.xml";
  6. ...
  7. myXMLfilenames[17] = file:///c:/bla/notesfromministry10.xml";
  8. indexofentries = 18;

 

I now get the content of the first file and analyze it...

  1. $.get(myXMLfilenames[0], function(d) {
  2.     //find each 'item' in the file and parse it
        $(d).find('entry').each(function() {
         var $item = $(this);

  3.      // grab label bla
         var strbla = $item.find('bla').text();
         // and the blub entry
         var strblub = $item.find('blub').text();


  4.      // put what you found into a long two-dimensional array
  5.      top.myXMLentries[top.indexofentries] = new Array();
         top.myXMLentries[top.indexofentries][0] = strblub;
         top.myXMLentries[top.indexofentries][1] = strbla;
         top.indexofentries++;


  6.    });
  7. });

 

In short, the first xml file gets read and when this is done, my declared function is called which analyzes the file's content and appends certain entries to a long "table" (well, a two dimensional array). As $.get() is called as a an asynchronous function, it is not certain when the declared function is called. As it is most important for me, to read and analyze every file only when the routine is finished with the last file (to make sure that the result array entries have the correct order - some of these files are huge while other are very short), the next $.get(...) call should probably get called from within my declared function (at the end) and should start some kind of recursion (?).

a) Is that possible?

b) How is it done? I tried to read about "arguments.callee", but I am not fit enough to get it done...

BTW, if it can be done using jQuery 1.2.6, I would be happy... :-) Ah, and before somebody asks... yes, everything is run on the local harddrive, so now web server is involved... a HTA will do the magic...

Thank you in advance for helping me,

Oliver