Created
February 4, 2010 05:18
-
-
Save polera/294341 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env python | |
from BeautifulSoup import BeautifulStoneSoup | |
xml_data = """<xml> | |
<response> | |
<results> | |
<result> | |
<fname>Brian</fname> | |
<lname>Jones</lname> | |
<gender>M</gender> | |
<office_phone_ext>777</office_phone_ext> | |
<mobile_phone>201-555-1212</mobile_phone> | |
</result> | |
<result> | |
<fname>Molly</fname> | |
<lname>Jones</lname> | |
<home_phone>201-555-1234</home_phone> | |
</result> | |
</results> | |
</response> | |
</xml>""" | |
xml = BeautifulStoneSoup(xml_data) | |
for result in xml.findAll("result"): | |
home_phone = getattr(result.home_phone,'string',None) | |
print home_phone |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment