Donnerstag, 14. März 2013

libxml2

What is libxml2
It is a library for processing XML documents. It is a library written in C and has bindings available for many languages, including C++, Perl, Python, PHP.

Compilation and Getting Started
1. Download source:
ftp://xmlsoft.org/libxml2/
# The latest version is indicated in the directory entries themselves

2. Run configure and build
sh
./configure
make

3. Compile and run a test program
gcc -Iinclude -L.libs -o testHTML testHTML.c -lxml2
:: Running the program testHTML.exe requires libxml2-2.dll to be in the PATH
set PATH=%PATH%;.libs
testHTML foo.html

4. Install headers
# Doing this from MSYS Console
mkdir "$USERPROFILE/include/libxml2/"
cp -rv include/libxml/ "$USERPROFILE/include/libxml2/"

5. Install libs
mkdir "$USERPROFILE/lib/libxml2/"
gnufind . -iname 'libxml*.a' -exec cp -v '{}' "$USERPROFILE/lib/libxml2/" ';'

6. Install DLLs
mkdir "$USERPROFILE/bin/libxml2/"
gnufind . -iname 'libxml*.dll' -exec cp -v '{}' "$USERPROFILE/bin/libxml2/" ';'

7. Install manpages
mkdir -p /c/cygwin/home/brandin/man/libxml2/man3
cp -v libxml.3 /c/cygwin/home/brandin/man/libxml2/man3/

8. Update environment
Add %USERPROFILE%\bin\libxml2 to PATH
Add %USERPROFILE%\include\libxml2 to CPATH
Add %USERPROFILE%\lib\libxml2 to LIBRARY_PATH
Add C:\cygwin\home\%USERNAME%\man\libxml2 to MANPATH
# Note: This environment will be added to env-mingw.bat

9. Try again to compile and run a test program meant for testing:
# Download the file reader1.c from the Web:
# URL: http://www.xmlsoft.org/examples/reader1.c
# Compile reader1
gcc -o reader1 reader1.c -lxml2

# Download a sample XML file for parsing and save it as sample.xml
# Example URL: http://en.wikipedia.org/w/index.php?title=Special:RecentChanges&feed=atom
# Use reader1 to parse the XML and save the result as reader1.out
reader1 sample.xml > reader1.out

References
http://www.gnu.org/software/dotgnu/pnetlib-doc/System/Xml/XmlNodeType.html
http://www.xmlsoft.org/examples/index.html

Keine Kommentare:

Kommentar veröffentlichen