Greetings: $$ can be used to query the current document using CSS selectors. Can the prototype library be used to query XML data stored within a javascript variable? Thanks --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Am 05.09.2007 um 16:44 schrieb JGHSBC:> Can the prototype library be used to query XML data stored within a > javascript variable?No. As an alternative, please look into storing data as JSON, as Prototype has support for that. best, thomas --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
You know, I''ve also had this same question and Christophe had a very similar response. JSON is shockingly not supported by a very broad spectrum. XML on the other hand is a very well supported data type, supported by countless systems in a variety of APIs, DOM being the biggest. Many times an ajax interface is integrated with a data model that can''t be changed, for instance an interface dealing with an RSS feed. I believe at this point the core team needs to seriously consider some form of support for CSS style selectors in an XML element. http://groups.google.com/group/rubyonrails-spinoffs/browse_thread/thread/7ab88758e366a468/e01de1a0b6c739bf?lnk=gst&q=xml+css&rnum=1#e01de1a0b6c739bf http://groups.google.com/group/rubyonrails-spinoffs/browse_thread/thread/b3be3f362f26cc99/818fdcacd4126e2b?lnk=st&q=&rnum=29#818fdcacd4126e2b As a make shift hack for JGHSBC you can do this. Granted I certainly haven''t thoroughly tested this but it worked for what I needed. //myXHR is the transport object that is being received. var myDiv = Element.extend(document.createElement("div")); myDiv.innerHTML = myXHR.responseText; var myCollection = myDiv.getElementsBySelector("rss item"); Cheers, Matt On Sep 5, 11:02 am, Thomas Fuchs <tho...-9D208sng4xU@public.gmane.org> wrote:> Am 05.09.2007 um 16:44 schrieb JGHSBC: > > > Can the prototype library be used to query XML data stored within a > > javascript variable? > > No. > > As an alternative, please look into storing data as JSON, as > Prototype has support for that. > > best, > thomas--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Converting XML to JSON is trivial server side.> Many times an ajax interface is integrated with a data model that > can''t be changed, for instance an interface dealing with an RSS feed.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Am 05.09.2007 um 17:31 schrieb Matt Foster:> You know, I''ve also had this same question and Christophe had a very > similar response. > > JSON is shockingly not supported by a very broad spectrum. > > XML on the other hand is a very well supported data type, supported by > countless systems in a variety of APIs, DOM being the biggest. > > Many times an ajax interface is integrated with a data model that > can''t be changed, for instance an interface dealing with an RSS feed. > > I believe at this point the core team needs to seriously consider some > form of support for CSS style selectors in an XML element.I understand the need for some to have an XML parser, but that isn''t Prototype core material -- of course this would make sense as an add-on. Also, as Tobie pointed out, converting server-side is trivial. Best, Thomas --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On Sep 6, 1:31 am, Matt Foster <mattfoste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: [...]> XML on the other hand is a very well supported data type, supported by > countless systems in a variety of APIs, DOM being the biggest. > > Many times an ajax interface is integrated with a data model that > can''t be changed, for instance an interface dealing with an RSS feed.I think you mean a language that can''t be changed.> I believe at this point the core team needs to seriously consider some > form of support for CSS style selectors in an XML element.Consider using XPath - it is likely that if a browser understands XML it will probaby understand XPath too. But count IE out - it has no idea about either.> As a make shift hack for JGHSBC you can do this. Granted I certainly > haven''t thoroughly tested this but it worked for what I needed. > > //myXHR is the transport object that is being received. > > var myDiv = Element.extend(document.createElement("div")); > > myDiv.innerHTML = myXHR.responseText; > > var myCollection = myDiv.getElementsBySelector("rss item");I don''t think you can depend on innerHTML being able to generate a useful document fragment if the markup really is XML, in any browser. It is defined as being a property of an HTML element and is a proprietary property of a browser that doesn''t know what XML is. -- Rob --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---