Donwload libxml2:
(Note: Always check on ftp://xmlsoft.org/libxml2/ for latest release available.)

wget ftp://xmlsoft.org/libxml2/libxml2-sources-2.6.32.tar.gz

Extracting files from the downloaded package:
tar -xvzf libxml2-sources-2.6.32.tar.gz

Now, enter the directory where the package is extracted.
cd libxml2-2.6.32

Configuring Libxml2 Library:
./configure --prefix=/usr/local/libxml2
(* Replace “/usr/local/libxml2″ above with the directory path where you want to copy the files and folders. Note: check for any error message.)

Compiling Libxml2:
make
Note: check for any error message.

Installing Libxml2:
make install

Configuring Libxml2 Library:
./configure --prefix=/usr/local/libxml2

If you need the development package, u can perform the same like above or do the following in Ubuntu:
sudo apt-get install libxml2-dev