Please allow me to rephrase my question into something much simple:

how can i preload an xml file into a jquery object, which means: an object i 
can then use in my jquery script like $(xml).find('element').attr('title')  ?


thank you for any help

Alex

---------- Original Message ----------
To: Jquery-en (jquery-en@googlegroups.com)
From: Alexandre Plennevaux ([EMAIL PROTECTED])
Subject: [jQuery] loading xml and search through it
Date: 28/1/2008 11:37:53

Hello,


This should be so easy yet i can't make it work. Here is what i'm trying to do: 
 i have a data structure stored as an xml file.

I need to load this structure once at the start of the application.
I need a function to search through this data structure and return the 
corresponding value.

So far i fail miserably because i don't quite get the synchronous/asynchronous 
side of jlife.

Here is the code i came up with :

// my searching function
function findProjectAnchor(projectName, scape){
    var thisDS = datascapeAnchorsXml.find('scape[title="' + scape + '"]');
    var myVal = $("item:contains('" + project + "')", thisDS).attr('rel');
    return myVal;
}

jQuery(function($){

    $.get("projects/datascapes.xml", {}, function(xmlData, strStatus){
        var datascapeAnchorsXml = $(xmlData);
    });




    /// this is how i call it:
    UI.dsAnchor = findProjectAnchor(UI.item, UI.sortBy);


    );

Problem is that the function is called before the xml gets loaded, thus returns 
"undefined". Any idea how i can make sure it does not perform the search before 
the xml is loaded?

thank you for your time and assistance,

Alexandre







Reply via email to