#! /usr/bin/python # -*- coding: utf-8 -*- import xml.dom.minidom # your xml string xmlContent = "..." # dom parser dom = xml.dom.minidom.parseString(xmlContent) # get element with tag "photo" photoList = dom.getElementsByTagName("photo") # get attribute id's value of each 'photo' element for photo in photoList: print photo.attributes['id'].value
#! /usr/bin/python # MyProgram.py # import sys module import sys # the relative path to this script "MyProgram.py" where you place your library (ex. ../MySQL/MySQLWrapper.py ) sys.path.append('../MySQL/') # import the library from MySQLWrapper import MySQLWrapper
I try to download python-mysqldb from " http://sourceforge.net/projects/mysql-python/" and run the build/install command: python setup.py build I receive this message: EnvironmentError: mysql_config not found I set mysql_config to "/opt/lampp/bin/mysql_config" (I use lampp) and encounter this error message: cc1: error: unrecognized command line option "-mpentiumpro" cc1: warning: command line option "-felide-constructors" is valid for C++/ObjC++ but not for C cc1: warning: command line option "-fno-rtti" is valid for C++/ObjC++ but not for C error: command 'gcc' failed with exit status 1 so I type sudo apt-get install python-mysqldb and find that I can finally import MySQLdb in python