Skip to content

Instantly share code, notes, and snippets.

@psd
Created April 29, 2014 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save psd/11402527 to your computer and use it in GitHub Desktop.
Save psd/11402527 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
from bs4 import BeautifulSoup
from json import JSONEncoder
def xml2json(text):
xml = BeautifulSoup(text, 'xml')
#print xml.prettify()
title = {
'title_number': xml.TitleNumber.string
}
return JSONEncoder().encode(title);
if __name__ == "__main__":
print xml2json(open('../concept-register-data/BD251159.xml'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment