[jQuery] Re: Parsing XML using "find()" has stopped working in jQuery 1.3+

2009-07-15 Thread skube

Although, I still think there is a BUG outstanding in 1.3.2.

Using the slightly more complicated find() below with 1.2.6 works in
both IE and Firefox:
$(xmlInitial).find("item:has(year:contains('2009')), item:has
(name:contains('2'))").each(function(){
   alert($(this).children('name').text());  // alerts 3 times
});

However, with 1.3.2 (with the above bug patch applied) in Firefox:
//alerts only 2 times

Finally, with 1.3.2 (with the above bug patch applied) in IE:
// gives a JS error: Number expected

Yet, using 1.3.2 with above bug patch applied, and a simplified find()
such as:
$(xmlInitial).find("item:has(year:contains('2009'))").each(function(){
   alert($(this).children('name').text());  // alerts 2 times as
expected in both IE/FF
});

Clearly, there are still some issues with jQuery 1.3.2 which prevent
me from upgrading.


[jQuery] Re: Parsing XML using "find()" has stopped working in jQuery 1.3+

2009-07-15 Thread skube

FYI, This appears to be a :contains() issue and is actually an older
bug which has resurfaced again with the introduction of jQuery 1.3.2

Older groups message:
http://groups.google.com/group/jquery-en/browse_thread/thread/f5c36c05cfa43e9a/90e3dfd019086772?#90e3dfd019086772

Bugtracker:
http://dev.jquery.com/ticket/1612


[jQuery] Re: Parsing XML and appending to an array?

2009-05-07 Thread chris thatcher
i think what you want is $('image', responsexml).each()

otherwise you are asking for each response element of which there is only
one.

On Thu, May 7, 2009 at 4:47 PM, Alan at DSI  wrote:

>
> I'm new to jQuery and what I am trying to do is take the XML response
> below and obtain the src attribute from each image. I then want to
> append that value to an array which can be used later. Now my issue is
> when it gets to
>
> Code:
>
> $('response', returnedXMLResponse).each(function(){ ... }
>
> it only iterates to the first row in the XML document and gives me
> 001.jpg when I output tmpImageSrc to console. It won't cycle through
> the rest of the image tags as the alert only appears once with a value
> of 0. What am I missing? Am I not using the proper .each? How can I
> build my array from the XML response?
>
> XML:
>
> 
> 
>
>
>
>
>
>
> 
>
> jQuery:
>
> 
>var imageList = [];
>var i = 0;
>$(document).ready(function(){
>// Get data and parse it into an array
>$.ajax({
>url: 'xmlResponse.xml',
>type: 'GET',
>dataType: 'xml',
>success: function(returnedXMLResponse){
>console.log(returnedXMLResponse);
>$('response', returnedXMLResponse).each(function()
> {
>var tmpImageSrc = $(this).find("image").attr
> ("src");
>console.log(tmpImageSrc);
>imageList.push(tmpImageSrc);
>alert(i);
>i++;
>})
>}  // End Success
>}); // End AJAX
>//console.log(imageList);
>});
> 
>



-- 
Christopher Thatcher


[jQuery] Re: Parsing XML with IE?

2009-05-07 Thread ScottChiefBaker

Wow that's sure is a unique bug. I was able to fix my script on the
server side by make sure the XML content was served as text/xml, this
caused an XMLObject to be returned which IE was able to process just
fine. Thanks for the heads up!

On May 7, 1:52 pm, Balazs Endresz  wrote:
> It's explained 
> here:http://groups.google.com/group/jquery-en/browse_frm/thread/95718c9aab...
>
> On May 7, 10:24 pm, ScottChiefBaker  wrote:
>
> > I created a simple test case:
>
> >http://www.perturb.org/tmp/jquery-test.html
>
> > On May 7, 12:41 pm, ScottChiefBaker  wrote:
>
> > > The following example works great in Firefox, and Chrome but fails
> > > miserably in IE (6,7,8). I'm running JQuery 1.3.2 if it makes a
> > > difference:
>
> > > $('resp',"value").text();
>
> > > That evaluates to "vaule" in everything except IE. Am I missing
> > > something?


[jQuery] Re: Parsing XML with IE?

2009-05-07 Thread Balazs Endresz

It's explained here:
http://groups.google.com/group/jquery-en/browse_frm/thread/95718c9aab2c7483/af37adcb54b816c3?lnk=gst&q=parsexml&pli=1

On May 7, 10:24 pm, ScottChiefBaker  wrote:
> I created a simple test case:
>
> http://www.perturb.org/tmp/jquery-test.html
>
> On May 7, 12:41 pm, ScottChiefBaker  wrote:
>
>
>
> > The following example works great in Firefox, and Chrome but fails
> > miserably in IE (6,7,8). I'm running JQuery 1.3.2 if it makes a
> > difference:
>
> > $('resp',"value").text();
>
> > That evaluates to "vaule" in everything except IE. Am I missing
> > something?


[jQuery] Re: Parsing XML with IE?

2009-05-07 Thread ScottChiefBaker

I created a simple test case:

http://www.perturb.org/tmp/jquery-test.html

On May 7, 12:41 pm, ScottChiefBaker  wrote:
> The following example works great in Firefox, and Chrome but fails
> miserably in IE (6,7,8). I'm running JQuery 1.3.2 if it makes a
> difference:
>
> $('resp',"value").text();
>
> That evaluates to "vaule" in everything except IE. Am I missing
> something?


[jQuery] Re: parsing xml

2009-01-02 Thread Balazs Endresz

jQuery can't really parse xml, only html.
But browsers can:
http://www.w3schools.com/Xml/xml_parser.asp

On Jan 2, 5:22 am, jhm  wrote:
> > jQuery needs a context for find() to work.
>
> That worked thanks! The xml file I was really using actually had a
> context similar. But it also had a header that was causing the
> problem. It was:
>
>    
>
> Any idea why this would break it?
>
> Thanks!


[jQuery] Re: parsing xml

2009-01-01 Thread jhm

> jQuery needs a context for find() to work.

That worked thanks! The xml file I was really using actually had a
context similar. But it also had a header that was causing the
problem. It was:

   

Any idea why this would break it?

Thanks!



[jQuery] Re: parsing xml

2009-01-01 Thread Ricardo Tomasi

Try using a base element:


sample one


sample two



jQuery needs a context for find() to work.

On Jan 1, 6:22 pm, jhm  wrote:
> I'm new to jquery and I'm trying to do a simple xml parse.
>
> When I use the .each() to get the tags, if there is more than one tag
> in the file, nothing more in the script gets processed. In the code
> below, you'll see two alerts. If I comment out the .each() line I get
> both alerts. If I leave it in, only the first appears and I never see
> any alerts from the .each() statement.
>
> Can anyone tell me what's wrong? Here's the code:
>
> -
>  "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd";>
> http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
> 
>   
>   
>   $(document).ready(function() {
>     $('.button').click(function() {
>       $.get('data.xml', function(data) {
>
>         $('#container').empty();
>         alert('one');
>
>         var html = $(data);
>         $('#container').append(html);
>
>         $(data).find('item').each(function(i) {
>           alert(i);
>         });
>
>         alert('two');
>       }, 'xml');
>     });
>   });
>   
> 
>
> 
>   Load
>   
>     some placeholder text
>   
> 
> -
>
> Here's the contents of data.xml:
>
> -
> 
>         sample one
> 
> 
>         sample two
> 
> -
>
> Remove the second item and it works with the .each() left in.
>
> Thanks!


[jQuery] Re: Parsing XML using jQuery

2008-07-12 Thread Diego A.
Hi there,

This plugin might be useful:

XML to JSON plugin v1.0
http://www.fyneworks.com/jquery/xml-to-json/

Cheers,
Diego A.

2008/7/9 Wallonman <[EMAIL PROTECTED]>:

>
> It seems that the DOM parsed 'on the fly' isn't ready for querying.
>
> When doing something weird like:
>
> var xml = $('Hello World!Bye World!');
> $(xml).appendTo("body");
>
> then the
>
> alert($("p").text());  // without context
>
> works !
>
>
>
>
>


-- 
Cheers,
Diego A.


[jQuery] Re: Parsing XML using jQuery

2008-07-09 Thread Wallonman

It seems that the DOM parsed 'on the fly' isn't ready for querying.

When doing something weird like:

var xml = $('Hello World!Bye World!');
$(xml).appendTo("body");

then the

alert($("p").text());  // without context

works !






[jQuery] Re: Parsing XML using jQuery

2008-07-09 Thread Alexandre Plennevaux

On Wed, Jul 9, 2008 at 12:38 PM, Wallonman <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> Some hours that I don't understand why this basic Xml parsing with
> JQuery doesn't work:
>
>$(document).ready(function() {
>
>var xml = '>Hello World!';
>
>alert($("p", xml).text());
>
>});
>
> I get an empty string, instead of the expected Hello World!
>
> I had a look to a similar previous post
> http://groups.google.com/group/jquery-en/browse_thread/thread/fc60b77f884e6866/85cbd666774c6780)
> , but this didn't help me to get the revelation.
>
>



try alert($("p", xml).eq(0).text());
-- 
Alexandre Plennevaux
LAb[au]

http://www.lab-au.com


[jQuery] Re: Parsing XML using jQuery

2008-01-29 Thread Dave Stewart

Thanks David and Tim,
I didn't know that. Very useful.


[jQuery] Re: Parsing XML using jQuery

2008-01-29 Thread Timothee Groleau

On Mon, 2008-01-28 at 17:39 -0800, Dave Stewart wrote:
> Not sure if this is the best reply, but in order to access the
> structure, it has to be part of the DOM,

That is not correct. You can build a jQuery instance from a xml object
and use the various jQuery query options to search through the xml tree
directly.


Step, have you tried the method find?

$(xml).find('building').each(function()
{
alert($(this).find('city_id').text());
});

hth,
Tim.


[jQuery] Re: Parsing XML using jQuery

2008-01-28 Thread Alexandre Plennevaux
the first try will not work with latest jquery, as xpath is now into a
seperate plugin. So stick to your second try. Also, make sure you search
your xml when the xml is actually loaded, so in the ajax function callback

$.ajax({//your params here}, function(xml,status){
if(status=='success'){
$('building', xml).each(function()
   {
   alert($("city_id", this).text(););
   });
}
});

cheers,

alex

On Jan 29, 2008 7:29 AM, David Serduke <[EMAIL PROTECTED]> wrote:

>
> Actually if it doesn't have to be part of the DOM assuming you are
> passing in a context as the second parameter of $() which the original
> author is.
>
> I don't use the xpath plugin so I'm not sure about that but the second
> attempt you said failed worked for me.  I got 3 alert boxes with '1',
> '2', '3' just as I expected.  Here is my test case.
>
> http://www.w3.org/
> TR/html4/strict.dtd">
> 
>  
>Tester
>
>
>
>
>  function doIt() {
>$.get("jquery_xml_load.xml", function (xml) {
>  $("building", xml).each(function () {
>alert($("city_id", this).text());
>  });
>});
>  }
>
>  $(document).ready(function() {
>$("button").click(doIt);
>  });
>
>  
>  
>Do It
>  
> 
>
> The xml file is a copy and paste of what you put in your post.  I
> think your problem is somewhere other than what you posted.
>
> Hope that helps.
>
> David
>



-- 
Alexandre Plennevaux
LAb[au]

http://www.lab-au.com


[jQuery] Re: Parsing XML using jQuery

2008-01-28 Thread David Serduke

Actually if it doesn't have to be part of the DOM assuming you are
passing in a context as the second parameter of $() which the original
author is.

I don't use the xpath plugin so I'm not sure about that but the second
attempt you said failed worked for me.  I got 3 alert boxes with '1',
'2', '3' just as I expected.  Here is my test case.

http://www.w3.org/
TR/html4/strict.dtd">

  
Tester




  function doIt() {
$.get("jquery_xml_load.xml", function (xml) {
  $("building", xml).each(function () {
alert($("city_id", this).text());
  });
});
  }

  $(document).ready(function() {
$("button").click(doIt);
  });

  
  
Do It
  


The xml file is a copy and paste of what you put in your post.  I
think your problem is somewhere other than what you posted.

Hope that helps.

David


[jQuery] Re: Parsing XML using jQuery

2008-01-28 Thread Dave Stewart

Not sure if this is the best reply, but in order to access the
structure, it has to be part of the DOM, so best to inject in into a
placeholder first:

$('#placeholder).html(xml) // probably need to kill the xml
declaration first

Then you can use jQuery to traverse the tree.

:D


[jQuery] Re: parsing xml

2007-07-17 Thread quez


Thanks for your help. This works but I kinda brute-forced my way
though. I'll see if I can implement it more clearly with this. Thanks.

On Jul 15, 1:57 pm, "Benjamin Sterling"
<[EMAIL PROTECTED]> wrote:
> Try:
> $('bio', this).text();
>
> On 7/15/07, quez <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > Benjamin, thanks for your reply.
>
> > I've started with the $.post func though like this: $.post("/
> > backend.php",{},function(xml){update_view(xml); } );
>
> > then: update_view(xml){
> > var messages = [] ;
> > $('message', xml).each( function(i){ //go through each message
>
> > $this = $(this); //jquery object.
> > messages[i] = {
> > bio: $this.find("bio").text(),
> > voted:$this.end().find("voted").text()
> > };
> > alert (messages[i][voted]);
>
> > }
>
> > }//end update_view
>
> > the alert is outputting an undefined value, and not the text as I
> > expected. I'll post a solution when I find it, but thanks very much
> > for your help.
>
> > On Jul 15, 11:04 am, "Benjamin Sterling"
> > <[EMAIL PROTECTED]> wrote:
> > > quez,
> > > I use the $.ajax with dataType set to xml; on success I set a global
> > > variable to the contents of the xml.  Once it is done, I get the info
> > doing
> > > something like:
>
> > > $('response/message:eq(0)/bio', globalXML).text();
>
> > > :eq(0) will grab the first message :eq(1) will grab the second one and
> > so
> > > on.
>
> > > I use this technique of a few sites,
> >http://airplume.informationexperts.com/module.htm#m-1000beingone of them.
>
> > > Check outhttp://airplume.informationexperts.com/common/js/core.jsand
> > look
> > > at the loadXML function at the bottom of the page and then look at the
> > > buildPage function that is about mid-way up the page and you will see
> > how I
> > > call everything in.
>
> > > On 7/14/07, quez <[EMAIL PROTECTED]> wrote:
>
> > > > my xml looks something like:
>
> > > > 
> > > >
> > > >the bio
> > > > the votes
> > > >
> > > >
> > > >another bio
> > > > likewise, another vote
> > > >
> > > > 
>
> > > > I'm new to jquery. I'd like to place these in an array so I can access
> > > > votes/bio easily and separately. at the moment, jquery is returning it
> > > > like this: "the bioanother bio" . Any help is much appreciated.
> > Thanks.
>
> > > --
> > > Benjamin Sterlinghttp://www.KenzoMedia.comhttp://www.KenzoHosting.com
>
> --
> Benjamin Sterlinghttp://www.KenzoMedia.comhttp://www.KenzoHosting.com



[jQuery] Re: parsing xml

2007-07-15 Thread Benjamin Sterling

Try:
$('bio', this).text();

On 7/15/07, quez <[EMAIL PROTECTED]> wrote:




Benjamin, thanks for your reply.

I've started with the $.post func though like this: $.post("/
backend.php",{},function(xml){update_view(xml); } );

then: update_view(xml){
var messages = [] ;
$('message', xml).each( function(i){ //go through each message

$this = $(this); //jquery object.
messages[i] = {
bio: $this.find("bio").text(),
voted:$this.end().find("voted").text()
};
alert (messages[i][voted]);

}

}//end update_view

the alert is outputting an undefined value, and not the text as I
expected. I'll post a solution when I find it, but thanks very much
for your help.

On Jul 15, 11:04 am, "Benjamin Sterling"
<[EMAIL PROTECTED]> wrote:
> quez,
> I use the $.ajax with dataType set to xml; on success I set a global
> variable to the contents of the xml.  Once it is done, I get the info
doing
> something like:
>
> $('response/message:eq(0)/bio', globalXML).text();
>
> :eq(0) will grab the first message :eq(1) will grab the second one and
so
> on.
>
> I use this technique of a few sites,
http://airplume.informationexperts.com/module.htm#m-1000being one of them.
>
> Check outhttp://airplume.informationexperts.com/common/js/core.jsand
look
> at the loadXML function at the bottom of the page and then look at the
> buildPage function that is about mid-way up the page and you will see
how I
> call everything in.
>
> On 7/14/07, quez <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > my xml looks something like:
>
> > 
> >
> >the bio
> > the votes
> >
> >
> >another bio
> > likewise, another vote
> >
> > 
>
> > I'm new to jquery. I'd like to place these in an array so I can access
> > votes/bio easily and separately. at the moment, jquery is returning it
> > like this: "the bioanother bio" . Any help is much appreciated.
Thanks.
>
> --
> Benjamin Sterlinghttp://www.KenzoMedia.comhttp://www.KenzoHosting.com





--
Benjamin Sterling
http://www.KenzoMedia.com
http://www.KenzoHosting.com


[jQuery] Re: parsing xml

2007-07-15 Thread quez


Benjamin, thanks for your reply.

I've started with the $.post func though like this: $.post("/
backend.php",{},function(xml){update_view(xml); } );

then: update_view(xml){
var messages = [] ;
$('message', xml).each( function(i){ //go through each message

$this = $(this); //jquery object.
messages[i] = {
bio: $this.find("bio").text(),
voted:$this.end().find("voted").text()
};
alert (messages[i][voted]);

}

}//end update_view

the alert is outputting an undefined value, and not the text as I
expected. I'll post a solution when I find it, but thanks very much
for your help.

On Jul 15, 11:04 am, "Benjamin Sterling"
<[EMAIL PROTECTED]> wrote:
> quez,
> I use the $.ajax with dataType set to xml; on success I set a global
> variable to the contents of the xml.  Once it is done, I get the info doing
> something like:
>
> $('response/message:eq(0)/bio', globalXML).text();
>
> :eq(0) will grab the first message :eq(1) will grab the second one and so
> on.
>
> I use this technique of a few 
> sites,http://airplume.informationexperts.com/module.htm#m-1000being one of 
> them.
>
> Check outhttp://airplume.informationexperts.com/common/js/core.jsand look
> at the loadXML function at the bottom of the page and then look at the
> buildPage function that is about mid-way up the page and you will see how I
> call everything in.
>
> On 7/14/07, quez <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > my xml looks something like:
>
> > 
> >
> >the bio
> > the votes
> >
> >
> >another bio
> > likewise, another vote
> >
> > 
>
> > I'm new to jquery. I'd like to place these in an array so I can access
> > votes/bio easily and separately. at the moment, jquery is returning it
> > like this: "the bioanother bio" . Any help is much appreciated. Thanks.
>
> --
> Benjamin Sterlinghttp://www.KenzoMedia.comhttp://www.KenzoHosting.com



[jQuery] Re: parsing xml

2007-07-15 Thread Benjamin Sterling

quez,
I use the $.ajax with dataType set to xml; on success I set a global
variable to the contents of the xml.  Once it is done, I get the info doing
something like:

$('response/message:eq(0)/bio', globalXML).text();

:eq(0) will grab the first message :eq(1) will grab the second one and so
on.

I use this technique of a few sites,
http://airplume.informationexperts.com/module.htm#m-1000 being one of them.

Check out http://airplume.informationexperts.com/common/js/core.js and look
at the loadXML function at the bottom of the page and then look at the
buildPage function that is about mid-way up the page and you will see how I
call everything in.

On 7/14/07, quez <[EMAIL PROTECTED]> wrote:



my xml looks something like:


   
   the bio
the votes
   
   
   another bio
likewise, another vote
   


I'm new to jquery. I'd like to place these in an array so I can access
votes/bio easily and separately. at the moment, jquery is returning it
like this: "the bioanother bio" . Any help is much appreciated. Thanks.





--
Benjamin Sterling
http://www.KenzoMedia.com
http://www.KenzoHosting.com


[jQuery] Re: parsing xml

2007-05-21 Thread gendruwo

Thanks, now im trying to do a search,
like for example $search = "Address"; from above xml format
how can i use the provided function in jquery to do the searching?
i tried using $("Field").find($search);
but doesnt seems to work... can someone enlighten me?


On May 17, 10:10 pm, Marc Jansen <[EMAIL PROTECTED]> wrote:
> gendruwo schrieb:
>
> > All,
>
> > if i have anxmlfile like this
>
> > 
> >   
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> >   
>
> > and i wanted to extract out the value for each name in the field, how
> > can i do it?
>
> > $("Field").attr(value)
>
> Hi,
> supposing you get theXMLvia a POST-Request you could do it like this:
>
> $.post('myurl.php', {'param1':'value1'}, function(response) {
>   console.log($('Field', response).attr('value'));
>
> });
>
> Or you could try this:
>
> $.post('myurl.php', {'param1':'value1'}, function(response) {
>   $('Field', response).each(function(){
> alert($(this).attr('value'));
>   });
>
> });
>
> untested as always.
>
> -- Marc



[jQuery] Re: parsing xml

2007-05-17 Thread Marc Jansen


gendruwo schrieb:

All,

if i have an xml file like this


  










  

and i wanted to extract out the value for each name in the field, how
can i do it?

$("Field").attr(value)

  

Hi,
supposing you get the XML via a POST-Request you could do it like this:

$.post('myurl.php', {'param1':'value1'}, function(response) {
 console.log($('Field', response).attr('value'));
});

Or you could try this:

$.post('myurl.php', {'param1':'value1'}, function(response) {
 $('Field', response).each(function(){
   alert($(this).attr('value'));
 });
});

untested as always.

-- Marc