Skip to content

Instantly share code, notes, and snippets.

@dac09
Created November 12, 2013 13:39
Show Gist options
  • Save dac09/7430967 to your computer and use it in GitHub Desktop.
Save dac09/7430967 to your computer and use it in GitHub Desktop.
Parsing XML with BeautifulSoup
from bs4 import BeautifulSoup as bs
import sys
f = open('1.xml').read()
soup = bs(f)
# print(soup.prettify()
errorcode = soup.find_all("errorcode")
try:
errorcode
except NameError:
errorcode = None
if errorcode is None:
print 'Its all good'
else:
print 'BOWM'
sys.exit(2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment