gaenewbie
gaenewbie

Reputation:

How do I parse XML from a Google App Engine app?

How do I parse XML from a Google App Engine app? Any examples?

Upvotes: 14

Views: 7035

Answers (3)

Richard Watson
Richard Watson

Reputation: 2614

Since the question was asked, Google has whitelisted pyexpat, which includes minidom, so you can use the following code without having to upload any libraries:

from xml.dom import minidom

dom = minidom.parseString('<eg>example text</eg>')

More information: http://docs.python.org/library/xml.dom.minidom.html

Upvotes: 20

jfs
jfs

Reputation: 414905

Take a look at existing answers on XML and Python.

Something like this could work:

from cStringIO   import StringIO
from xml.etree   import cElementTree as etree

xml = "<a>aaa<b>bbb</b></a>"

for event, elem in etree.iterparse(StringIO(xml)):
    print elem.text

It prints:

bbb
aaa

Upvotes: 8

joschi
joschi

Reputation: 13101

AFAIK Google App Engine provides a fairly complete Python environment for you to use. Since Python comes with "batteries included" you may want to evaluate the different APIs which vanilla Python offers you: http://docs.python.org/library/markup.html

Upvotes: 4

Related Questions