Hello! I''m having some problems with Firefox in my Ajax script. I''m using prototype/scriptaculous. This is the code: var workplaces transport.responseXML.getElementsByTagName(''workplace''); for (var i = 0; i<workplaces.length; i++) { var node = workplaces[i]; var name = node.getElementsByTagName(''newslink'') [0].firstChild.nodeValue; alert(name); } The "alert" returns nothing, it''s just empty. In IE6 it returns the value I want to see. This is the xml I am using: <?xml version="1.0" encoding="UTF-8" ?> <worlplace_info> <workplace> <newslink> <![CDATA[ <a href="/cm/1.635" >utan ort</a> (9 maj) ]]> </newslink> </worlplace_info> Anyonte got any ideas as to what may be causing this??? thnx JOhan --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
try innerText, the dom implementation could be different for nodeValue On 5/15/07, theMuffinMan <johan.a.edlund-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Hello! I''m having some problems with Firefox in my Ajax script. I''m > using prototype/scriptaculous. > This is the code: > > var workplaces > transport.responseXML.getElementsByTagName(''workplace''); > for (var i = 0; i<workplaces.length; i++) > { > var node = workplaces[i]; > var name = node.getElementsByTagName(''newslink'') > [0].firstChild.nodeValue; > alert(name); > } > > The "alert" returns nothing, it''s just empty. In IE6 it returns the > value I want to see. This is the xml I am using: > <?xml version="1.0" encoding="UTF-8" ?> > <worlplace_info> > <workplace> > <newslink> > <![CDATA[ > <a href="/cm/1.635" >utan ort</a> (9 maj) > > > ]]> > </newslink> > </worlplace_info> > > Anyonte got any ideas as to what may be causing this??? > > thnx > JOhan > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 May 15, 7:20 pm, "Gareth Evans" <agr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> try innerText, the dom implementation could be different for nodeValueFirefox doesn''t support IE''s proprietary innerText property, it supports the W3C equivalent: textContent. Neither are equivalent to innerHTML. -- 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 -~----------~----~----~----~------~----~------~--~---
Oops my bad. I didn''t google, of course.. I just have found that when coding for IE (I mostly do intranet apps where firefox isn''t standard, sadly) that node.value doesn''t always contain what you expect and it''s better to use the text property. The equiv to innerHTML, unparsed would be .xml on a node, wouldn''t it? On 5/15/07, RobG <rgqld-AFFH1GffN5hPR4JQBCEnsQ@public.gmane.org> wrote:> > > On May 15, 7:20 pm, "Gareth Evans" <agr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > try innerText, the dom implementation could be different for nodeValue > > Firefox doesn''t support IE''s proprietary innerText property, it > supports the W3C equivalent: textContent. Neither are equivalent to > innerHTML. > > -- > 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 -~----------~----~----~----~------~----~------~--~---
Thanks guys! So, should I write like this? var name = node.getElementsByTagName(''newslink'') [0].firstChild.Text; or: var name = node.getElementsByTagName(''newslink'') [0].firstChild.textContent; ? They just return ''undefined'' for me. thnkx /Johan On 15 Maj, 12:17, "Gareth Evans" <agr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Oops my bad. I didn''t google, of course.. I just have found that when coding > for IE (I mostly do intranet apps where firefox isn''t standard, sadly) that > node.value doesn''t always contain what you expect and it''s better to use the > text property. The equiv to innerHTML, unparsed would be .xml on a node, > wouldn''t it? > > On 5/15/07, RobG <r...-AFFH1GffN5hPR4JQBCEnsQ@public.gmane.org> wrote: > > > > > On May 15, 7:20 pm, "Gareth Evans" <agr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > try innerText, the dom implementation could be different for nodeValue > > > Firefox doesn''t support IE''s proprietary innerText property, it > > supports the W3C equivalent: textContent. Neither are equivalent to > > innerHTML. > > > -- > > 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 -~----------~----~----~----~------~----~------~--~---
On May 15, 8:53 pm, theMuffinMan <johan.a.edl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thanks guys! > > So, should I write like this? > var name = node.getElementsByTagName(''newslink'') > [0].firstChild.Text; > > or: > > var name = node.getElementsByTagName(''newslink'') > [0].firstChild.textContent;I don''t use XML this way, for HTML documents I use either JSON or HTML fragments. To get the CDATA of an XML node, you need to use the DOMString attribute of the Text node holds the text that is contained by the CDATA section: <URL: http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-667469212 > There are likely others here who can give you better advice. -- 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 -~----------~----~----~----~------~----~------~--~---