1. 安装expat开发库
1.1. apt-get
$sudo apt-get install libexpat-dev
1.2. 源码安装
1.2.1. 获取源码
expat-2.0.1.tar.gz(http://sourceforge.net/projects/expat/)
***or***
$checkout: $cvs -z3 -d:pserver:anonymous@expat.cvs.sourceforge.net:/cvsroot/expat co expat
1.2.2. 编译安装
$tar xzvf expat-2.0.1.tar.gz
$cd expat-2.0.1
$./configure --prefix=/usr
$make
$sudo make install
2. 小例子
2.1.c源码
2.2.demo.xml
2.3. 编译运行
$gcc helloexpat.c -lexpat
$./a.out
输出:--------------------------------------------------------------
root:
element1: attr1="#attr1" attr2="#attr2"
element11: attr1="#attr1" attr2="#attr2"
element12: attr1="#attr1" attr2="#attr2"
element1: attr1="#attr1" attr2="#attr2"
element11: attr1="#attr1" attr2="#attr2"
element12: attr1="#attr1" attr2="#attr2"