Hello there, im having a problem with the xml handling, i want to get and xml node and put things in an input text but im a little lost, im using this code, but isn''t work, what am i doing wrong? --------------------- <a href="#" onclick="getXML()">Get XML</a> <input type="text" value="nothing here" id="respuesta" /> <script type="text/javascript"> function getXML(){ var url = ''emperors.xml''; var myAjax = new Ajax.Request( url, { method: ''get'', onComplete: showResponse }); } function showResponse(originalRequest){ var xml = originalRequest.responseText; var x = xml.getElementsByTagName(''emperor''); $(''respuesta'').value = x[0].childNodes[0].nodeName; } </script> --------------------- regards -- // // Ing. Francisco J. Calderón S. // fjcalderon-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org // Usuario de GNU/Linux nº 349529 // Maracay, Venezuela // _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Make sure the response you are receiving is XML and not Text in case you want to traverse through XML. Check it by checking the responseHeaders(). Hope this helps! Thank you, Mandy. _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
On 3/3/06, Maninder, Singh <mandiv-W2hqgAdRMsX2eFz/2MeuCQ@public.gmane.org> wrote:> > Make sure the response you are receiving is XML and not Text in case you > want to traverse through XML. > > Check it by checking the responseHeaders().how? i put this function showResponse(originalRequest){ alert(originalRequest.responseHeaders); << new line to see the headers var xml = originalRequest.responseText; var x = xml.getElementsByTagName(''emperor''); $(''respuesta'').value = x[0].childNodes[0].nodeName; } but is not working Hope this helps!> > Thank you, > Mandy. > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >-- // // Ing. Francisco J. Calderón S. // fjcalderon-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org // Usuario de GNU/Linux nº 349529 // Maracay, Venezuela // _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
i did it, the problem was i am using var xml = originalRequest.responseText; i need to use this var xml = originalRequest.responseXML; thx a lot On 3/3/06, Maninder, Singh <mandiv-W2hqgAdRMsX2eFz/2MeuCQ@public.gmane.org> wrote:> > Make sure the response you are receiving is XML and not Text in case you > want to traverse through XML. > > Check it by checking the responseHeaders(). > > Hope this helps! > > Thank you, > Mandy. > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >-- // // Ing. Francisco J. Calderón S. // fjcalderon-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org // Usuario de GNU/Linux nº 349529 // Maracay, Venezuela // _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs