<?xml version="1.0" encoding="utf-8" ?> <rsp stat="ok"> <method>flickr.test.echo</method> <name>value</name> <api_key>7c7ac3c40f14a809XXXX</api_key> </rsp> | から valueを取り出す。 |
from google.appengine.api import urlfetch
from xml.dom import minidom
url="http://api.flickr.com/services/rest/?method=flickr.test.echo&name=value&api_key=XXX"
result = urlfetch.fetch(url)
print "---result"
print result
print "---result.content"
print result.content
dom = minidom.parseString(result.content)
r =dom.getElementsByTagName('name')[0].firstChild.data
print "---dom.getElementsByTagName"
print r
<?xml version="1.0" encoding="utf-8" ?> <rsp stat="fail"> <err code="100" msg="Invalid API Key (Key not found)" /> &l | からfail を取り出すにはdom.getElementsByTagName('rsp')[0].getAttribute('stat') |