Created
March 16, 2010 18:00
-
-
Save rdegges/334300 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sys import exit | |
from lxml import etree | |
response = 'some xml response here' | |
try: | |
doc = etree.XML(response.strip()) | |
code = doc.findtext('code') | |
print code | |
except etree.XMLSyntaxError: | |
print 'XML parsing error.' | |
exit(1) | |
if code == '200': | |
# store the id somewhere | |
id = doc.findtext('id') | |
else: | |
# handle errors, do more stuff | |
print doc.findtext('error') | |
exit(1) | |
exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment