dac09
11/12/2013 - 1:39 PM

Parsing XML with BeautifulSoup

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)