Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bs4 as BeautifulSoup
- def pretty_xml(filename):
- content = open(filename)
- soup=BeautifulSoup.BeautifulSoup(content)
- output = soup.prettify().encode('utf-8')
- outputname = filename+str('.pretty')
- outputfile = open(outputname,'w')
- for line in output:
- try:
- outputfile.write(line.encode('utf-8'))
- except: pass
- outputfile.close()
- print "File created as",outputname
- filename = str(raw_input('Enter filename >'))
- pretty_xml(filename)
- """ This program takes xml code and prints an output file
- that is prettified using the BeautifulSoup module.
- The output file has the same name as the input file
- with a '.pretty' suffix added to it.
- Just type in the filename and get some prettier code """
Advertisement
Add Comment
Please, Sign In to add comment