Libxml Tutorial
John Fleck <jfleck@inkstain.net>
Copyright © 2002, 2003 John Fleck
Revision History
Revision 1 June 4, 2002
Initial draft
Revision 2 June 12, 2002
retrieving attribute value added
Revision 3 Aug. 31, 2002
freeing memory fix
Revision 4 Nov. 10, 2002
encoding discussion added
Revision 5 Dec. 15, 2002
more memory freeing changes
Revision 6 Jan. 26. 2003
add index
Revision 7 April 25, 2003
add compilation appendix
Revision 8 July 24, 2003
add XPath example
Revision 9 Feb. 14, 2004
Fix bug in XPath example
Revision 7 Aug. 24, 2004
Fix another bug in XPath example
Table of Contents
Introduction ...............................................................................2
Data Types ................................................................................2
Parsing the file ...........................................................................3
Retrieving Element Content .......................................................... 3
Using XPath to Retrieve Element Content ........................................ 4
Writing element content ............................................................... 6
Writing Attribute ........................................................................6
Retrieving Attributes ...................................................................7
Encoding Conversion ...................................................................8
A. Compilation ...........................................................................9
B. Sample Document ...................................................................9
C. Code for Keyword Example ......................................................9
D. Code for XPath Example ........................................................ 10
E. Code for Add Keyword Example .............................................. 12
F. Code for Add Attribute Example .............................................. 13
G. Code for Retrieving Attribute Value Example ............................. 14
H. Code for Encoding Conversion Example ................................... 15
I. Acknowledgements ................................................................ 16
Abstract
Libxml is a freely licensed C language library for handling XML, portable
1