thanks, the only difference i spot is that you call the function when the
ajax loading is successful. but  i need to call that function many time
afterwards, and i was logging  a message to the console when the loading is
finished and it always occured before i was actually calling the function,
yet it didn't work. I could even log the xml.responseText, so it was loaded.
the traversing just didn't work. I ended up modifying the xml structure
(simplify it by removing one level, using it as an attribute of the item
node), and it works now.

anyway, thank you for your help chrismarx!

On Jan 22, 2008 3:20 AM, chrismarx <[EMAIL PROTECTED]> wrote:

>
> this returned a myVal of 2007:
>
>  $(document).ready(function(){
>                $.ajax({
>                type:   "GET",
>                url:    "jquery_test.xml", //your xml
>                data:   "",
>                dataType:       "xml",
>                success: function(data,textStatus) {
>                         findAnchor("test-release","time",data);
>                },
>                error: function(msg) {
>                      //call function to pass friendly message back to
> thread and
> end "fetching"
>                      //opts.onFail();
>                }
>         });
>
>                function findAnchor(projectName,scape, xml){
>                var myscape = $("scape[title='" + scape + "']", xml);
>                var myItem = $('item[title="' + projectName + '"]',
> myscape);
>                var myCol  = $(myItem).parent();
>                myVal = $(myCol).attr('title');
>                alert("dsanchor for " + projectName + "in scape:UI.sortBy="
> +
> myVal);
>                return myVal;
>            }
>    });
>
>
>
>
> On Jan 21, 4:49 pm, "Alexandre Plennevaux" <[EMAIL PROTECTED]>
> wrote:
> > Hello again,
> >
> > i'm banging my head on this issue:
> >
> > I'm using a function to search through a small bit xml. It works more or
> less except that the returned value is not correct.
> >
> > Here is my function:
> >
> >     function findAnchor(projectName,scape, xml){
> >         var myscape = $("scape[title='" + scape + "']", xml.responseText
> );
> >         var myItem = $('item[title="' + projectName + '"]', myscape);
> >                 var myCol  = $(myItem).parent();
> >                 myVal = $(myCol).attr('title');
> >         $.log("dsanchor for " + projectName + " in scape:" + UI.sortBy +
> "=" + myVal);
> >         return myVal;
> >     }
> >
> >     The xml file is herebelow. Now, if i try :  var dsAnchorVar =
> findAnchor('test-release','time', xml);
> >
> >     it returns "time", whereas it should return "2007".  Can you tell me
> why ? It seems to me the .parent(); selector does not function...
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <datascapes>
> >         <scape title="title">
> >                 <col title="L">
> >                         <item title="liquidspace" />
> >                         <item title="liquidspace01" />
> >                 </col>
> >                 <col title="S">
> >                         <item title="space-navigable-music" />
> >                 </col>
> >                 <col title="T">
> >                         <item title="test-release" />
> >                         <item title="touch" />
> >
> >                 </col>
> >         </scape>
> >         <scape title="time">
> >                 <col title="2004">
> >                         <item title="electric_courtship_songs" />
> >                 </col>
> >                 <col title="2004">
> >                         <item title="liquidspace02" />
> >                 </col>
> >                 <col title="2007">
> >                         <item title="liquidspace03" />
> >                 </col>
> >                 <col title="2000">
> >                         <item title="space-navigable-music" />
> >                 </col>
> >                 <col title="2007">
> >                         <item title="test-release" />
> >                 </col>
> >                 <col title="2006">
> >                         <item title="touch" />
> >                 </col>
> >         </scape>
> > </datascapes>
> >
> > Alexandre
>



-- 
Alexandre Plennevaux
LAb[au]

http://www.lab-au.com

Reply via email to