Skip to main content

Posts

Showing posts from April, 2010

Get attribute name and value of XML using minidom module in Python

#! /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

Install python-mysqldb with lampp on Ubuntu

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