Ok it does returns a string, magically everything is fine now thanks for all the help!
On Mon, Apr 13, 2009 at 4:49 PM, Marcelo de Sena Lacerda < marceloslace...@gmail.com> wrote: > Yes, I needed to set the headers. Thanks! > However I still don't know what should I do to convert the exit of to_xml() > from the model class into something useful. Any ideas? > > > On Tue, Mar 24, 2009 at 10:41 AM, Gijsbert <gijsbert.de.h...@gmail.com>wrote: > >> >> You could use Live HTTP Headers in Firefox (for instance) to make sure >> that the browser is getting valid data. >> Maybe you need to set the content-type of the response to 'text/xml' >> for the browser to initialize responseXML: >> >> self.response.headers['Content-Type'] = 'text/xml' >> >> On Mar 23, 11:10 am, Marcelo Sena <marceloslace...@gmail.com> wrote: >> > So I tried a more direct approach to this problem: >> > >> > function stateChanged() >> > { >> > if (xmlHttp.readyState==4) >> > { >> > if (xmlHttp.responseXML==null)alert("Null"); >> > var xmlDoc=xmlHttp.responseXML.documentElement; >> > document.getElementById("companyname").innerHTML= >> > xmlDoc.getElementsByTagName("compname")[0].childNodes[0].nodeValue; >> > document.getElementById("contactname").innerHTML= >> > xmlDoc.getElementsByTagName("contname")[0].childNodes[0].nodeValue; >> > document.getElementById("address").innerHTML= >> > xmlDoc.getElementsByTagName("address")[0].childNodes[0].nodeValue; >> > document.getElementById("city").innerHTML= >> > xmlDoc.getElementsByTagName("city")[0].childNodes[0].nodeValue; >> > document.getElementById("country").innerHTML= >> > xmlDoc.getElementsByTagName("country")[0].childNodes[0].nodeValue; >> > >> > } >> > } >> > >> > The responseXML is always null so the line after the alert box always >> > crashes. >> > >> > Here is the response handler I'm using: >> > >> > class getANote(webapp.RequestHandler): >> > def get(self): >> > #query=Models.NoteModel.all() >> > #fnote=query.get() >> > >> > self.response.out.write('''<?xml version='1.0' >> > encoding='ISO-8859-1'?> >> > <company> >> > <compname>Foo</compname> >> > <contname>bar</contname> >> > <address>ball</address> >> > <city>bwal</city> >> > <country>XD</country> >> > </company> >> > ''') >> > >> > The xml is said well formatted using w3c validator. Now what I'm doing >> > wrong, is this a app engine error? Help please! >> > >> > On Mar 20, 9:53 pm, Marcelo Sena <marceloslace...@gmail.com> wrote: >> > >> > > Here is my model: >> > > class NoteModel(db.Model): >> > > title = db.StringProperty(multiline=False) >> > > content = db.ListProperty(type('string')) >> > > And the values are: >> > > title:'Foo' >> > > content: ['bar'] >> > >> > > And the result of: >> > >> > > class getANote(webapp.RequestHandler): >> > > def get(self): >> > > query=Models.NoteModel.all() >> > > fnote=query.get() >> > > xmlrep=fnote.to_xml() >> > >> > > self.response.out.write(xmlrep) >> > >> > > called from: >> > >> > > function stateChanged() >> > > { >> > > if (xmlHttp.readyState==4) >> > > { >> > > var xmlDoc=xmlHttp.responseXML; >> > > document.getElementById("txtHint").innerHTML=xmlDoc; >> > >> > > } >> > >> > > } >> > >> > > But the result is: >> > >> > > Exactly, nothing. What am I doing wrong? >> > >> > > On Mar 20, 4:25 pm, Marcelo Sena <marceloslace...@gmail.com> wrote: >> > >> > > > I know what the docs say, but what kind of xml is that, is a string >> or >> > > > a object and what is the type of that object? I tried using type() >> on >> > > > it and it returned nothing. >> > > > I need to turn my model into a XML to use it in a javascript. >> > > > Regards, >> > > > Marcelo Sena. >> > >> > >> >> >> > > > -- > Marcelo Sena > -- Marcelo Sena --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~----------~----~----~----~------~----~------~--~---