Hi all, I am trying to send data to a GAE app in xml format via http POST request. The GAE application is supposed to parse it.
Code handling POST request in GAE is class Guestbook(webapp.RequestHandler): def post(self): global val_list guestbook_name = self.request.get('guestbook_name') greeting = Greeting(parent=guestbook_key(guestbook_name)) sensor_val = self.request.get('content') greeting.content = sensor_val greeting.put() Code for displaying parsed value on browser is class MainPage(webapp.RequestHandler): def get(self): self.response.out.write('<html><body>') guestbook_name=self.request.get('guestbook_name') greetings = db.GqlQuery("SELECT * " "FROM Greeting " "WHERE ANCESTOR IS :1 " "ORDER BY date DESC LIMIT 10", guestbook_key(guestbook_name)) for greeting in greetings: val = cgi.escape(greeting.content) dom_val = minidom.parseString(val) val_pretty = dom_val.toprettyxml() self.response.out.write('<blockquote>%s</blockquote>' %val_pretty) The problem is, when I use a string directly in above code as dom_val = minidom.parseString('<eg>example text</eg>') The code parses the xml string successfully. However when I send the string from a client application as h = httplib2.Http() form_fields = { 'content': '<eg>example text</eg>' } data = urllib.urlencode(form_fields) resp, content = h.request('http://107.108.58.183:8080/sign', 'POST', data , headers={'Content-Type': 'application/x-www-form-urlencoded'}) Following error happens while parsing Traceback (most recent call last): File "/home/asd/google_app_engine/google_appengine/google/appengine/ ext/webapp/__init__.py", line 700, in __call__ handler.get(*groups) File "/home/asd/google_app_engine/projects/sensor_xml/ helloworld.py", line 44, in get dom_val = minidom.parseString(val) File "/usr/lib/python2.7/xml/dom/minidom.py", line 1924, in parseString return expatbuilder.parseString(string) File "/usr/lib/python2.7/xml/dom/expatbuilder.py", line 940, in parseString return builder.parseString(string) File "/usr/lib/python2.7/xml/dom/expatbuilder.py", line 223, in parseString parser.Parse(string, True) ExpatError: not well-formed (invalid token): line 1, column 0 The string is received by GAE as I am able to print it by printing variable var successfully. however parsing it as xml generates the error. Please help. -- 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.