I''ve got an XML file which is pretty well structured. I need to retrieve specific elements from that file to fill out empty HTML elements on a page. I think what I need is xPath? Or - is that overkill? Is there some easier way to locate an XML element? What I have in mind is pulling the XML file using Ajax, then xPath to get the bits I need. Am I on the right path and does prototype have an xPath capability? Sam _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
humm.. as far as i know if your server delivers an XML file as text/xml or something similar then Ajax.request will fill responseXML which contains the xml-doctree. With that you can use the common DOM functions to wade through all the data and then fill your elements as you like. Hope this helps. 2006/7/24, Sam <sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org>:> > > I''ve got an XML file which is pretty well structured. I need to retrieve > specific elements from that file to fill out empty HTML elements on a page. > > I think what I need is xPath? Or - is that overkill? Is there some > easier way to locate an XML element? > > What I have in mind is pulling the XML file using Ajax, then xPath to get > the bits I need. > > Am I on the right path and does prototype have an xPath capability? > > Sam > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Here''s a nice library supporting xpath... http://sarissa.sourceforge.net/doc/ On 7/24/06, Sam <sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org> wrote:> > > I''ve got an XML file which is pretty well structured. I need to retrieve > specific elements from that file to fill out empty HTML elements on a page. > > I think what I need is xPath? Or - is that overkill? Is there some > easier way to locate an XML element? > > What I have in mind is pulling the XML file using Ajax, then xPath to get > the bits I need. > > Am I on the right path and does prototype have an xPath capability? > > Sam > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
If this XML file isn''t a DOCTYPE (not a html/body/tag document), should I expect Ajax responseXML to build out an xml-doctree or should I move on to xPath? Sam -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Kjell Bublitz Sent: Monday, July 24, 2006 11:37 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails-spinoffs] XML Question humm.. as far as i know if your server delivers an XML file as text/xml or something similar then Ajax.request will fill responseXML which contains the xml-doctree. With that you can use the common DOM functions to wade through all the data and then fill your elements as you like. Hope this helps. 2006/7/24, Sam <sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org>: I''ve got an XML file which is pretty well structured. I need to retrieve specific elements from that file to fill out empty HTML elements on a page. I think what I need is xPath? Or - is that overkill? Is there some easier way to locate an XML element? What I have in mind is pulling the XML file using Ajax, then xPath to get the bits I need. Am I on the right path and does prototype have an xPath capability? Sam _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org <mailto:Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
I don''t understand your question right, but in some ways this understanding seems to be correct. Have you just tried to request the xml document with the ajax class and had a look into responseXML ? Here is how i do it. (copied from my recent project): new Ajax.Request(tplpath + ''system/workdir/blocks.xml'', { method:''get'', requestHeaders:[''cache-control'',''no-cache'',''pragma'',''no-cache''], onComplete:function(xmlresult) { if(xmlresult.responseXML.firstChild.nodeName == ''bloxpress'') { // check if first child is as expected Bloxpress.blocksParse(xmlresult.responseXML); // pass the responseXML to a function } else { var blockMenuDiv = Builder.node(''div'', {id:''contentmenu'', style:''display:none''},[''No Blocks available'']); $(blockMenuTarget).appendChild(blockMenuDiv); Bloxpress.blocksMenu = $(''contentmenu''); } } }); 2006/7/24, Sam <sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org>:> > If this XML file isn''t a DOCTYPE (not a html/body/tag document), should I > expect Ajax responseXML to build out an xml-doctree or should I move on to > xPath? > > Sam > > > -----Original Message----- > *From:* rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto: > rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] *On Behalf Of *Kjell Bublitz > *Sent:* Monday, July 24, 2006 11:37 AM > *To:* rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > *Subject:* Re: [Rails-spinoffs] XML Question > > humm.. as far as i know if your server delivers an XML file as text/xml or > something similar then Ajax.request will fill responseXML which contains > the xml-doctree. With that you can use the common DOM functions to wade > through all the data and then fill your elements as you like. > > Hope this helps. > > 2006/7/24, Sam <sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org>: > > > > > > I''ve got an XML file which is pretty well structured. I need to > > retrieve specific elements from that file to fill out empty HTML elements on > > a page. > > > > I think what I need is xPath? Or - is that overkill? Is there some > > easier way to locate an XML element? > > > > What I have in mind is pulling the XML file using Ajax, then xPath to > > get the bits I need. > > > > Am I on the right path and does prototype have an xPath capability? > > > > Sam > > > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
... is the responseXML below available only in Mozilla? I get nada in IE. Sam -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Kjell Bublitz Sent: Monday, July 24, 2006 4:19 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails-spinoffs] XML Question I don''t understand your question right, but in some ways this understanding seems to be correct. Have you just tried to request the xml document with the ajax class and had a look into responseXML ? Here is how i do it. (copied from my recent project): new Ajax.Request(tplpath + ''system/workdir/blocks.xml'', { method:''get'', requestHeaders:[''cache-control'',''no-cache'',''pragma'',''no-cache''], onComplete:function(xmlresult) { if( xmlresult.responseXML.firstChild.nodeName =''bloxpress'') { // check if first child is as expected Bloxpress.blocksParse(xmlresult.responseXML); // pass the responseXML to a function } else { var blockMenuDiv = Builder.node(''div'', {id:''contentmenu'', style:''display:none''},[''No Blocks available'']); $(blockMenuTarget).appendChild(blockMenuDiv); Bloxpress.blocksMenu = $(''contentmenu''); } } }); 2006/7/24, Sam <sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org >: If this XML file isn''t a DOCTYPE (not a html/body/tag document), should I expect Ajax responseXML to build out an xml-doctree or should I move on to xPath? Sam -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Kjell Bublitz Sent: Monday, July 24, 2006 11:37 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails-spinoffs] XML Question humm.. as far as i know if your server delivers an XML file as text/xml or something similar then Ajax.request will fill responseXML which contains the xml-doctree. With that you can use the common DOM functions to wade through all the data and then fill your elements as you like. Hope this helps. 2006/7/24, Sam <sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org>: I''ve got an XML file which is pretty well structured. I need to retrieve specific elements from that file to fill out empty HTML elements on a page. I think what I need is xPath? Or - is that overkill? Is there some easier way to locate an XML element? What I have in mind is pulling the XML file using Ajax, then xPath to get the bits I need. Am I on the right path and does prototype have an xPath capability? Sam _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org <mailto:Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org <mailto:Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
No, it''s available. You might have to say responseXML.documentElement (not sure, but I always do and it works). Oh, and you could try changing ''get'' to ''post''. I''ve always had moderate to bad success in IE with ''GET'' requests on Ajax. Even with no arguments, sometimes IE just chokes on ''GET''. Haven''t really researched why it does that, but ''POST'' has fixed it in every case. If you look through the archives, I posted a script that takes an xml document and parses it into a nested javascript hash, for quick and easy access to nested tags in JS. Might be useful to you, might not. Source is here: http://greg.kathihill.com/content/jbhv/web/default/js/xml_doc.js It doesn''t handle every type of XML tag, so you might need to expand it to cover more. Example of usage: show: function (response) { var xmlDoc = new XMLDoc(response.responseXML.documentElement); var results = xmlDoc.asHash(); if (results.found && results.found.length > 0) { // any <found> tags are included in this array, it''s always an array, even if it has just one element // attributes and text-only nodes are included as text, so results.found[0].id could be: // <found id="1" /> or <found><id>1</id></found> } } Anyhoo, if that helps, use it. If it doesn''t, then bugger off :-) I find it simplifies a lot of code for me. Greg ________________________________ From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Sam Sent: Friday, July 28, 2006 11:17 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: RE: [Rails-spinoffs] XML Question ... is the responseXML below available only in Mozilla? I get nada in IE. Sam -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Kjell Bublitz Sent: Monday, July 24, 2006 4:19 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails-spinoffs] XML Question I don''t understand your question right, but in some ways this understanding seems to be correct. Have you just tried to request the xml document with the ajax class and had a look into responseXML ? Here is how i do it. (copied from my recent project): new Ajax.Request(tplpath + ''system/workdir/blocks.xml'', { method:''get'', requestHeaders:[''cache-control'',''no-cache'',''pragma'',''no-cache''], onComplete:function(xmlresult) { if( xmlresult.responseXML.firstChild.nodeName =''bloxpress'') { // check if first child is as expected Bloxpress.blocksParse(xmlresult.responseXML); // pass the responseXML to a function } else { var blockMenuDiv = Builder.node(''div'', {id:''contentmenu'', style:''display:none''},[''No Blocks available'']); $(blockMenuTarget).appendChild(blockMenuDiv); Bloxpress.blocksMenu = $(''contentmenu''); } } }); 2006/7/24, Sam <sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org >: If this XML file isn''t a DOCTYPE (not a html/body/tag document), should I expect Ajax responseXML to build out an xml-doctree or should I move on to xPath? Sam -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Kjell Bublitz Sent: Monday, July 24, 2006 11:37 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails-spinoffs] XML Question humm.. as far as i know if your server delivers an XML file as text/xml or something similar then Ajax.request will fill responseXML which contains the xml-doctree. With that you can use the common DOM functions to wade through all the data and then fill your elements as you like. Hope this helps. 2006/7/24, Sam <sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org>: I''ve got an XML file which is pretty well structured. I need to retrieve specific elements from that file to fill out empty HTML elements on a page. I think what I need is xPath? Or - is that overkill? Is there some easier way to locate an XML element? What I have in mind is pulling the XML file using Ajax, then xPath to get the bits I need. Am I on the right path and does prototype have an xPath capability? Sam _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Thanks (a lot! ). I''ve had to rule out including a 100Kb xPath.js library. Maybe this lib is a better solution. I diagnosed the problem with IE responseXML - if the file isn''t served "up" as text/xml, IE doesn''t make responseXML available. (I was testing on my local hard-disk / no server). Posting to a server solves this problem. I can (will) live with that. Sam -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Hill, Greg Sent: Friday, July 28, 2006 1:37 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: RE: [Rails-spinoffs] XML Question No, it''s available. You might have to say responseXML.documentElement (not sure, but I always do and it works). Oh, and you could try changing ''get'' to ''post''. I''ve always had moderate to bad success in IE with ''GET'' requests on Ajax. Even with no arguments, sometimes IE just chokes on ''GET''. Haven''t really researched why it does that, but ''POST'' has fixed it in every case. If you look through the archives, I posted a script that takes an xml document and parses it into a nested javascript hash, for quick and easy access to nested tags in JS. Might be useful to you, might not. Source is here: http://greg.kathihill.com/content/jbhv/web/default/js/xml_doc.js It doesn''t handle every type of XML tag, so you might need to expand it to cover more. Example of usage: show: function (response) { var xmlDoc = new XMLDoc(response.responseXML.documentElement); var results = xmlDoc.asHash(); if (results.found && results.found.length > 0) { // any <found> tags are included in this array, it''s always an array, even if it has just one element // attributes and text-only nodes are included as text, so results.found[0].id could be: // <found id="1" /> or <found><id>1</id></found> } } Anyhoo, if that helps, use it. If it doesn''t, then bugger off :-) I find it simplifies a lot of code for me. Greg _____ From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Sam Sent: Friday, July 28, 2006 11:17 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: RE: [Rails-spinoffs] XML Question ... is the responseXML below available only in Mozilla? I get nada in IE. Sam -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Kjell Bublitz Sent: Monday, July 24, 2006 4:19 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails-spinoffs] XML Question I don''t understand your question right, but in some ways this understanding seems to be correct. Have you just tried to request the xml document with the ajax class and had a look into responseXML ? Here is how i do it. (copied from my recent project): new Ajax.Request(tplpath + ''system/workdir/blocks.xml'', { method:''get'', requestHeaders:[''cache-control'',''no-cache'',''pragma'',''no-cache''], onComplete:function(xmlresult) { if( xmlresult.responseXML.firstChild.nodeName =''bloxpress'') { // check if first child is as expected Bloxpress.blocksParse(xmlresult.responseXML); // pass the responseXML to a function } else { var blockMenuDiv = Builder.node(''div'', {id:''contentmenu'', style:''display:none''},[''No Blocks available'']); $(blockMenuTarget).appendChild(blockMenuDiv); Bloxpress.blocksMenu = $(''contentmenu''); } } }); 2006/7/24, Sam <sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org >: If this XML file isn''t a DOCTYPE (not a html/body/tag document), should I expect Ajax responseXML to build out an xml-doctree or should I move on to xPath? Sam -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Kjell Bublitz Sent: Monday, July 24, 2006 11:37 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails-spinoffs] XML Question humm.. as far as i know if your server delivers an XML file as text/xml or something similar then Ajax.request will fill responseXML which contains the xml-doctree. With that you can use the common DOM functions to wade through all the data and then fill your elements as you like. Hope this helps. 2006/7/24, Sam <sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org>: I''ve got an XML file which is pretty well structured. I need to retrieve specific elements from that file to fill out empty HTML elements on a page. I think what I need is xPath? Or - is that overkill? Is there some easier way to locate an XML element? What I have in mind is pulling the XML file using Ajax, then xPath to get the bits I need. Am I on the right path and does prototype have an xPath capability? Sam _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org <mailto:Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org <mailto:Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Well, I''m sure xPath is a lot more flexible, but holy crap is that a lot of code. As I said, mine is limited, but serves my purposes very well. And it''s generic enough for anyone to use, although it only handles node types 1 to 3. Anything beyond that will be ignored (or possibly break it, I haven''t tested it thoroughly against other node types). http://www.devguru.com/Technologies/xmldom/quickref/obj_node.html#types (node type information) Greg ________________________________ From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Sam Sent: Friday, July 28, 2006 11:43 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: RE: [Rails-spinoffs] XML Question Thanks (a lot! ). I''ve had to rule out including a 100Kb xPath.js library. Maybe this lib is a better solution. I diagnosed the problem with IE responseXML - if the file isn''t served "up" as text/xml, IE doesn''t make responseXML available. (I was testing on my local hard-disk / no server). Posting to a server solves this problem. I can (will) live with that. Sam _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Greg, OK, there''s objects in objects. Nice... For debugging purposes, what''s the simplest way to convert the entire returned object to a string for inspection? Sam -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Hill, Greg Sent: Friday, July 28, 2006 1:57 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: RE: [Rails-spinoffs] XML Question Well, I''m sure xPath is a lot more flexible, but holy crap is that a lot of code. As I said, mine is limited, but serves my purposes very well. And it''s generic enough for anyone to use, although it only handles node types 1 to 3. Anything beyond that will be ignored (or possibly break it, I haven''t tested it thoroughly against other node types). http://www.devguru.com/Technologies/xmldom/quickref/obj_node.html#types (node type information) Greg _____ From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Sam Sent: Friday, July 28, 2006 11:43 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: RE: [Rails-spinoffs] XML Question Thanks (a lot! ). I''ve had to rule out including a 100Kb xPath.js library. Maybe this lib is a better solution. I diagnosed the problem with IE responseXML - if the file isn''t served "up" as text/xml, IE doesn''t make responseXML available. (I was testing on my local hard-disk / no server). Posting to a server solves this problem. I can (will) live with that. Sam _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Is Prototype''s inspect function recursive? If it is, then $H(results).inspect() would work. Otherwise, you''ll have to come up with your own recursive function. Greg ________________________________ From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Sam Sent: Friday, July 28, 2006 12:33 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: RE: [Rails-spinoffs] XML Question Greg, OK, there''s objects in objects. Nice... For debugging purposes, what''s the simplest way to convert the entire returned object to a string for inspection? Sam -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Hill, Greg Sent: Friday, July 28, 2006 1:57 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: RE: [Rails-spinoffs] XML Question Well, I''m sure xPath is a lot more flexible, but holy crap is that a lot of code. As I said, mine is limited, but serves my purposes very well. And it''s generic enough for anyone to use, although it only handles node types 1 to 3. Anything beyond that will be ignored (or possibly break it, I haven''t tested it thoroughly against other node types). http://www.devguru.com/Technologies/xmldom/quickref/obj_node.html#types (node type information) Greg ________________________________ From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Sam Sent: Friday, July 28, 2006 11:43 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: RE: [Rails-spinoffs] XML Question Thanks (a lot! ). I''ve had to rule out including a 100Kb xPath.js library. Maybe this lib is a better solution. I diagnosed the problem with IE responseXML - if the file isn''t served "up" as text/xml, IE doesn''t make responseXML available. (I was testing on my local hard-disk / no server). Posting to a server solves this problem. I can (will) live with that. Sam _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
>> what''s the simplest way to convert the entire returned object to a stringfor inspection use responseText instead? On 7/28/06, Sam <sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org> wrote:> > Greg, > > OK, there''s objects in objects. Nice... > > For debugging purposes, what''s the simplest way to convert the entire > returned object to a string for inspection? > > Sam > > -----Original Message----- > *From:* rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto: > rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] *On Behalf Of *Hill, Greg > *Sent:* Friday, July 28, 2006 1:57 PM > *To:* rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > *Subject:* RE: [Rails-spinoffs] XML Question > > Well, I''m sure xPath is a lot more flexible, but holy crap is that a lot > of code. As I said, mine is limited, but serves my purposes very well. And > it''s generic enough for anyone to use, although it only handles node types 1 > to 3. Anything beyond that will be ignored (or possibly break it, I haven''t > tested it thoroughly against other node types). > > > > http://www.devguru.com/Technologies/xmldom/quickref/obj_node.html#types(node type information) > > > > Greg > > > ------------------------------ > > *From:* rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto: > rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] *On Behalf Of *Sam > *Sent:* Friday, July 28, 2006 11:43 AM > *To:* rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > *Subject:* RE: [Rails-spinoffs] XML Question > > > > Thanks (a lot! ). I''ve had to rule out including a 100Kb xPath.jslibrary. Maybe this lib is a better solution. > > > > I diagnosed the problem with IE responseXML - if the file isn''t served > "up" as text/xml, IE doesn''t make responseXML available. (I was testing on > my local hard-disk / no server). Posting to a server solves this problem. > I can (will) live with that. > > > > Sam > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
I''ve had my Ajax XML reader working for a week now. Then I hit a snag late in the game (doesn''t work in IE) explained by Dean Edwards: http://dean.edwards.name/weblog/2006/04/easy-xml/ Since request.requestXML.documentElement isn''t available in IE, I''m experimenting with using the requestXML and searching the tree using getElementsByTagName. I''m confounded by not being able to read the element attributes. Here''s a line of the XML: <Module name="this is a name" attr="abcde"> request.requestXML.getElementsByTagName(''Module'')[0] // this will locate <Module but... how to I get the value of attr? It seems it should be request.requestXML.getElementsByTagName(''Module'')[0].attr // but it doesn''t exist... Any ideas? Sam _____ From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Sam Sent: Friday, July 28, 2006 1:17 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: RE: [Rails-spinoffs] XML Question ... is the responseXML below available only in Mozilla? I get nada in IE. Sam -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Kjell Bublitz Sent: Monday, July 24, 2006 4:19 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails-spinoffs] XML Question I don''t understand your question right, but in some ways this understanding seems to be correct. Have you just tried to request the xml document with the ajax class and had a look into responseXML ? Here is how i do it. (copied from my recent project): new Ajax.Request(tplpath + ''system/workdir/blocks.xml'', { method:''get'', requestHeaders:[''cache-control'',''no-cache'',''pragma'',''no-cache''], onComplete:function(xmlresult) { if( xmlresult.responseXML.firstChild.nodeName =''bloxpress'') { // check if first child is as expected Bloxpress.blocksParse(xmlresult.responseXML); // pass the responseXML to a function } else { var blockMenuDiv = Builder.node(''div'', {id:''contentmenu'', style:''display:none''},[''No Blocks available'']); $(blockMenuTarget).appendChild(blockMenuDiv); Bloxpress.blocksMenu = $(''contentmenu''); } } }); 2006/7/24, Sam <sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org >: If this XML file isn''t a DOCTYPE (not a html/body/tag document), should I expect Ajax responseXML to build out an xml-doctree or should I move on to xPath? Sam -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Kjell Bublitz Sent: Monday, July 24, 2006 11:37 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails-spinoffs] XML Question humm.. as far as i know if your server delivers an XML file as text/xml or something similar then Ajax.request will fill responseXML which contains the xml-doctree. With that you can use the common DOM functions to wade through all the data and then fill your elements as you like. Hope this helps. 2006/7/24, Sam <sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org>: I''ve got an XML file which is pretty well structured. I need to retrieve specific elements from that file to fill out empty HTML elements on a page. I think what I need is xPath? Or - is that overkill? Is there some easier way to locate an XML element? What I have in mind is pulling the XML file using Ajax, then xPath to get the bits I need. Am I on the right path and does prototype have an xPath capability? Sam _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org <mailto:Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org <mailto:Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
I believe you have to use the getAttribute() method when navigating XML to get the attribute values. I''ve heard rumors that you can use documentElement in IE as long as your document mime type is set to ''text/xml'' for the XML you''re retrieving. But I don''t have an XML source I can use to test just now. :P Has anybody had any luck with this? Thanks! -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org]On Behalf Of Sam Sent: Sunday, August 13, 2006 10:29 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: RE: [Rails-spinoffs] XML Question I''ve had my Ajax XML reader working for a week now. Then I hit a snag late in the game (doesn''t work in IE) explained by Dean Edwards: http://dean.edwards.name/weblog/2006/04/easy-xml/ Since request.requestXML.documentElement isn''t available in IE, I''m experimenting with using the requestXML and searching the tree using getElementsByTagName. I''m confounded by not being able to read the element attributes. Here''s a line of the XML: <Module name="this is a name" attr="abcde"> request.requestXML.getElementsByTagName(''Module'')[0] // this will locate <Module but... how to I get the value of attr? It seems it should be request.requestXML.getElementsByTagName(''Module'')[0].attr // but it doesn''t exist... Any ideas? Sam _____ From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Sam Sent: Friday, July 28, 2006 1:17 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: RE: [Rails-spinoffs] XML Question ... is the responseXML below available only in Mozilla? I get nada in IE. Sam -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Kjell Bublitz Sent: Monday, July 24, 2006 4:19 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails-spinoffs] XML Question I don''t understand your question right, but in some ways this understanding seems to be correct. Have you just tried to request the xml document with the ajax class and had a look into responseXML ? Here is how i do it. (copied from my recent project): new Ajax.Request(tplpath + ''system/workdir/blocks.xml'', { method:''get'', requestHeaders:[''cache-control'',''no-cache'',''pragma'',''no-cache''], onComplete:function(xmlresult) { if( xmlresult.responseXML.firstChild.nodeName == ''bloxpress'') { // check if first child is as expected Bloxpress.blocksParse(xmlresult.responseXML); // pass the responseXML to a function } else { var blockMenuDiv = Builder.node(''div'', {id:''contentmenu'', style:''display:none''},[''No Blocks available'']); $(blockMenuTarget).appendChild(blockMenuDiv); Bloxpress.blocksMenu = $(''contentmenu''); } } }); 2006/7/24, Sam < sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org >: If this XML file isn''t a DOCTYPE (not a html/body/tag document), should I expect Ajax responseXML to build out an xml-doctree or should I move on to xPath? Sam -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Kjell Bublitz Sent: Monday, July 24, 2006 11:37 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails-spinoffs] XML Question humm.. as far as i know if your server delivers an XML file as text/xml or something similar then Ajax.request will fill responseXML which contains the xml-doctree. With that you can use the common DOM functions to wade through all the data and then fill your elements as you like. Hope this helps. 2006/7/24, Sam < sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org>: I''ve got an XML file which is pretty well structured. I need to retrieve specific elements from that file to fill out empty HTML elements on a page. I think what I need is xPath? Or - is that overkill? Is there some easier way to locate an XML element? What I have in mind is pulling the XML file using Ajax, then xPath to get the bits I need. Am I on the right path and does prototype have an xPath capability? Sam _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org <mailto:Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org <mailto:Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
After reading the replies to Dean''s article http://dean.edwards.name/weblog/2006/04/easy-xml/ it turns out that IE does support requestXML.documentElement , at least, Dean found that it did work after a while, but he doesn''t explain what changed. To my complete amazement, it''s working for me too. I wish I knew why. Nothing has changed here. Sam _____ From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Sam Sent: Sunday, August 13, 2006 10:29 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: RE: [Rails-spinoffs] XML Question I''ve had my Ajax XML reader working for a week now. Then I hit a snag late in the game (doesn''t work in IE) explained by Dean Edwards: http://dean.edwards.name/weblog/2006/04/easy-xml/ Since request.requestXML.documentElement isn''t available in IE, I''m experimenting with using the requestXML and searching the tree using getElementsByTagName. I''m confounded by not being able to read the element attributes. Here''s a line of the XML: <Module name="this is a name" attr="abcde"> request.requestXML.getElementsByTagName(''Module'')[0] // this will locate <Module but... how to I get the value of attr? It seems it should be request.requestXML.getElementsByTagName(''Module'')[0].attr // but it doesn''t exist... Any ideas? Sam _____ From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Sam Sent: Friday, July 28, 2006 1:17 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: RE: [Rails-spinoffs] XML Question ... is the responseXML below available only in Mozilla? I get nada in IE. Sam -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Kjell Bublitz Sent: Monday, July 24, 2006 4:19 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails-spinoffs] XML Question I don''t understand your question right, but in some ways this understanding seems to be correct. Have you just tried to request the xml document with the ajax class and had a look into responseXML ? Here is how i do it. (copied from my recent project): new Ajax.Request(tplpath + ''system/workdir/blocks.xml'', { method:''get'', requestHeaders:[''cache-control'',''no-cache'',''pragma'',''no-cache''], onComplete:function(xmlresult) { if( xmlresult.responseXML.firstChild.nodeName =''bloxpress'') { // check if first child is as expected Bloxpress.blocksParse(xmlresult.responseXML); // pass the responseXML to a function } else { var blockMenuDiv = Builder.node(''div'', {id:''contentmenu'', style:''display:none''},[''No Blocks available'']); $(blockMenuTarget).appendChild(blockMenuDiv); Bloxpress.blocksMenu = $(''contentmenu''); } } }); 2006/7/24, Sam <sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org >: If this XML file isn''t a DOCTYPE (not a html/body/tag document), should I expect Ajax responseXML to build out an xml-doctree or should I move on to xPath? Sam -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Kjell Bublitz Sent: Monday, July 24, 2006 11:37 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails-spinoffs] XML Question humm.. as far as i know if your server delivers an XML file as text/xml or something similar then Ajax.request will fill responseXML which contains the xml-doctree. With that you can use the common DOM functions to wade through all the data and then fill your elements as you like. Hope this helps. 2006/7/24, Sam <sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org>: I''ve got an XML file which is pretty well structured. I need to retrieve specific elements from that file to fill out empty HTML elements on a page. I think what I need is xPath? Or - is that overkill? Is there some easier way to locate an XML element? What I have in mind is pulling the XML file using Ajax, then xPath to get the bits I need. Am I on the right path and does prototype have an xPath capability? Sam _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org <mailto:Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org <mailto:Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
I''ve always been able to get the documentElement in IE, but I''ve always used text/xml, so maybe that is the key. Greg ________________________________ From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Bauser, Joseph (Joe) Sent: Monday, August 14, 2006 8:25 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: RE: [Rails-spinoffs] XML Question I believe you have to use the getAttribute() method when navigating XML to get the attribute values. I''ve heard rumors that you can use documentElement in IE as long as your document mime type is set to ''text/xml'' for the XML you''re retrieving. But I don''t have an XML source I can use to test just now. :P Has anybody had any luck with this? Thanks! -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org]On Behalf Of Sam Sent: Sunday, August 13, 2006 10:29 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: RE: [Rails-spinoffs] XML Question I''ve had my Ajax XML reader working for a week now. Then I hit a snag late in the game (doesn''t work in IE) explained by Dean Edwards: http://dean.edwards.name/weblog/2006/04/easy-xml/ Since request.requestXML.documentElement isn''t available in IE, I''m experimenting with using the requestXML and searching the tree using getElementsByTagName. I''m confounded by not being able to read the element attributes. Here''s a line of the XML: <Module name="this is a name" attr="abcde"> request.requestXML.getElementsByTagName(''Module'')[0] // this will locate <Module but... how to I get the value of attr? It seems it should be request.requestXML.getElementsByTagName(''Module'')[0].attr // but it doesn''t exist... Any ideas? Sam ________________________________ From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Sam Sent: Friday, July 28, 2006 1:17 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: RE: [Rails-spinoffs] XML Question ... is the responseXML below available only in Mozilla? I get nada in IE. Sam -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Kjell Bublitz Sent: Monday, July 24, 2006 4:19 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails-spinoffs] XML Question I don''t understand your question right, but in some ways this understanding seems to be correct. Have you just tried to request the xml document with the ajax class and had a look into responseXML ? Here is how i do it. (copied from my recent project): new Ajax.Request(tplpath + ''system/workdir/blocks.xml'', { method:''get'', requestHeaders:[''cache-control'',''no-cache'',''pragma'',''no-cache''], onComplete:function(xmlresult) { if( xmlresult.responseXML.firstChild.nodeName == ''bloxpress'') { // check if first child is as expected Bloxpress.blocksParse(xmlresult.responseXML); // pass the responseXML to a function } else { var blockMenuDiv Builder.node(''div'', {id:''contentmenu'', style:''display:none''},[''No Blocks available'']); $(blockMenuTarget).appendChild(blockMenuDiv); Bloxpress.blocksMenu $(''contentmenu''); } } }); 2006/7/24, Sam <sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org >: If this XML file isn''t a DOCTYPE (not a html/body/tag document), should I expect Ajax responseXML to build out an xml-doctree or should I move on to xPath? Sam -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Kjell Bublitz Sent: Monday, July 24, 2006 11:37 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails-spinoffs] XML Question humm.. as far as i know if your server delivers an XML file as text/xml or something similar then Ajax.request will fill responseXML which contains the xml-doctree. With that you can use the common DOM functions to wade through all the data and then fill your elements as you like. Hope this helps. 2006/7/24, Sam <sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org>: I''ve got an XML file which is pretty well structured. I need to retrieve specific elements from that file to fill out empty HTML elements on a page. I think what I need is xPath? Or - is that overkill? Is there some easier way to locate an XML element? What I have in mind is pulling the XML file using Ajax, then xPath to get the bits I need. Am I on the right path and does prototype have an xPath capability? Sam _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs