The XML-LibXML CPAN Distribution for Processing XML using the libxml2 library
Perl C XS HTML Other
Switch branches/tags
release_1_30 axkit XML-LibXML-2.0132 XML-LibXML-2.0131 XML-LibXML-2.0130 XML-LibXML-2.0129 XML-LibXML-2.0128 XML-LibXML-2.0127 XML-LibXML-2.0126 XML-LibXML-2.0125 XML-LibXML-2.0124 XML-LibXML-2.0123 XML-LibXML-2.0122 XML-LibXML-2.0121 XML-LibXML-2.0120 XML-LibXML-2.0119 XML-LibXML-2.0118 XML-LibXML-2.0117 XML-LibXML-2.0116 XML-LibXML-2.0115 XML-LibXML-2.0114 XML-LibXML-2.0113 XML-LibXML-2.0112 XML-LibXML-2.0111 XML-LibXML-2.0110 XML-LibXML-2.0109 XML-LibXML-2.0108 XML-LibXML-2.0107 XML-LibXML-2.0106 XML-LibXML-2.0105 XML-LibXML-2.0104 XML-LibXML-2.0103 XML-LibXML-2.0102 XML-LibXML-2.0101 XML-LibXML-2.0100 XML-LibXML-2.0019 XML-LibXML-2.0018 XML-LibXML-2.0017 XML-LibXML-2.0016 XML-LibXML-2.0015 XML-LibXML-2.0012 XML-LibXML-2.0011 XML-LibXML-2.0010 XML-LibXML-2.0009 XML-LibXML-2.0008 XML-LibXML-2.0007 XML-LibXML-2.0006 XML-LibXML-2.0005 XML-LibXML-2.0004 XML-LibXML-2.0003 XML-LibXML-2.0002 XML-LibXML-2.0001 XML-LibXML-2.0000 XML-LibXML-1.99 XML-LibXML-1.98 XML-LibXML-1.97 XML-LibXML-1.96 XML-LibXML-1.95 XML-LibXML-1.94 XML-LibXML-1.93 XML-LibXML-1.92 XML-LibXML-1.91 XML-LibXML-1.90 XML-LibXML-1.89 XML-LibXML-1.88 XML-LibXML-1.87 XML-LibXML-1.86 XML-LibXML-1.85 XML-LibXML-1.84 XML-LibXML-1.83 XML-LibXML-1.82 XML-LibXML-1.81 XML-LibXML-1.80 XML-LibXML-1.79 XML-LibXML-1.78 XML-LibXML-1.77 XML-LibXML-1.76 XML-LibXML-1.75 XML-LibXML-1.74 XML-LibXML-1.73 XML-LibXML-1.72 XML-LibXML-1.71 XML-LibXML-1_40 XML-LibXML-0_96 XML-LibXML-0_92 XML-LibXML-0_91 CPAN_1_58_1 CPAN_1_58 CPAN_1_57 CPAN_1_56 CPAN_1_55 CPAN_1_54_3 CPAN_1_54_2 CPAN_1_54_1 CPAN_1_54_0 CPAN_1_54 CPAN_1_52 CPAN_1_51 CPAN_1_50
Nothing to show
Clone or download
Latest commit abc3a97 Jan 10, 2018
Failed to load latest commit information.
debian Remove some old files Jun 1, 2016
docs bump version to 2.0132 Oct 28, 2017
example Cleanups. Sep 17, 2016
inc/Devel Support libxml2 builds with disabled xmlReader Apr 4, 2014
lib/XML/LibXML bump version to 2.0132 Oct 28, 2017
scripts Add a script for automating the build + test. Oct 26, 2017
t Revert setNamespace() enhancements that broke some dependent tests: Oct 28, 2017
test Remove some old files Jun 1, 2016
.gitignore Add .gitignore. May 30, 2016
.hgignore Support libxml2 builds with disabled xmlReader Apr 4, 2014
.travis.yml Travis: try to debug failed build. Jan 9, 2018
Av_CharPtrPtr.c Support libxml2 builds with disabled xmlReader Apr 4, 2014
Av_CharPtrPtr.h Support libxml2 builds with disabled xmlReader Apr 4, 2014
Changes Revert setNamespace() enhancements that broke some dependent tests: Oct 28, 2017
Devel.xs Support libxml2 builds with disabled xmlReader Apr 4, 2014
HACKING.txt Support libxml2 builds with disabled xmlReader Apr 4, 2014
LICENSE Support libxml2 builds with disabled xmlReader Apr 4, 2014 bump version to 2.0132 Oct 28, 2017
LibXML.xs Fix trailing space and formatting. Oct 23, 2017
MANIFEST Revert setNamespace() enhancements that broke some dependent tests: Oct 28, 2017
Makefile.PL fixup postamble runtest target Jan 9, 2018
PHISHS.CHANGES Remove some old files Jun 1, 2016
README Change the strings and URLs to point to GitHub. May 30, 2016
TODO Support libxml2 builds with disabled xmlReader Apr 4, 2014
appveyor.yml try appveyor fix Jan 9, 2018
dom.c Update dom.c Jul 12, 2017
dom.h Support libxml2 builds with disabled xmlReader Apr 4, 2014
perl-libxml-mm.c Fix MSVC compilation issues Jan 9, 2018
perl-libxml-mm.h Support libxml2 builds with disabled xmlReader Apr 4, 2014
perl-libxml-sax.c Fix MSVC compilation issues Jan 9, 2018
perl-libxml-sax.h Fix MSVC compilation issues Jan 9, 2018
ppport.h Support libxml2 builds with disabled xmlReader Apr 4, 2014 Support libxml2 builds with disabled xmlReader Apr 4, 2014
typemap Support libxml2 builds with disabled xmlReader Apr 4, 2014
xpath.c Support libxml2 builds with disabled xmlReader Apr 4, 2014
xpath.h Support libxml2 builds with disabled xmlReader Apr 4, 2014
xpathcontext.h Support libxml2 builds with disabled xmlReader Apr 4, 2014



This module implements a Perl interface to the Gnome libxml2 library which
provides interfaces for parsing and manipulating XML files. This module allows
Perl programmers to make use of the highly capable validating XML parser and
the high performance DOM implementation.


XML::LibXML was almost entirely reimplemented between version 1.40 to version
1.49. This may cause problems on some production machines. With version 1.50 a
lot of compatibility fixes were applied, so programs written for XML::LibXML
1.40 or less should run with version 1.50 again.

In 1.59, a new callback API was introduced. This new API is not compatible with
the previous one. See XML::LibXML::InputCallback manual page for details.

In 1.61 the XML::LibXML::XPathContext module, previously distributed
separately, was merged in.

An experimental support for Perl threads introduced in 1.66 has been replaced
in 1.67.


Prior to installation you MUST have installed the libxml2 library. You can get
the latest libxml2 version from

Without libxml2 installed this module will neither build nor run.

Also XML::LibXML requires the following packages:

   o XML::SAX - base class for SAX parsers
   o XML::NamespaceSupport - namespace support for SAX parsers

These packages are required. If one is missing some tests will fail.

Again, libxml2 is required to make XML::LibXML work. The library is not just
required to build XML::LibXML, it has to be accessible during run-time as well.
Because of this you need to make sure libxml2 is installed properly. To test
this, run the xmllint program on your system. xmllint is shipped with libxml2
and therefore should be available. For building the module you will also need
the header file for libxml2, which in binary (.rpm,.deb) etc. distributions
usually dwell in a package named libxml2-devel or similar.


(These instructions are for UNIX and GNU/Linux systems. For MSWin32, See Notes
for Microsoft Windows below.)

To install XML::LibXML just follow the standard installation routine for Perl

   1 perl Makefile.PL
   2 make
   3 make test
   4 make install # as superuser

Note that XML::LibXML is an XS based Perl extension and you need a C compiler
to build it.

Note also that you should rebuild XML::LibXML if you upgrade libxml2 in order
to avoid problems with possible binary incompatibilities between releases of
the library.

Notes on libxml2 versions

XML::LibXML requires at least libxml2 2.6.16 to compile and pass all tests and
at least 2.6.21 is required for XML::LibXML::Reader. For some older OS versions
this means that an update of the pre-built packages is required.

Although libxml2 claims binary compatibility between its patch levels, it is a
good idea to recompile XML::LibXML and run its tests after an upgrade of

If your libxml2 installation is not within your $PATH, you can pass the
XMLPREFIX=$YOURLIBXMLPREFIX parameter to Makefile.PL determining the correct
libxml2 version in use. e.g.

>  perl Makefile.PL XMLPREFIX=/usr/brand-new

will ask '/usr/brand-new/bin/xml2-config' about your real libxml2

Try to avoid setting INC and LIBS directly on the command-line, for if used,
Makefile.PL does not check the libxml2 version for compatibility with

Which version of libxml2 should be used?

XML::LibXML is tested against a couple versions of libxml2 before it is
released. Thus there are versions of libxml2 that are known not to work
properly with XML::LibXML. The Makefile.PL keeps a blacklist of the
incompatible libxml2 versions.

If Makefile.PL detects one of the incompatible versions, it notifies the user.
It may still happen that XML::LibXML builds and pass its tests with such a
version, but that does not mean everything is OK. There will be no support at
all for blacklisted versions!

As of XML::LibXML 1.61, only versions 2.6.16 and higher are supported.
XML::LibXML will probably not compile with earlier libxml2 versions than 2.5.6.
Versions prior to 2.6.8 are known to be broken for various reasons, versions
prior to 2.1.16 exhibit problems with namespaced attributes and do not
therefore pass XML::LibXML regression tests.

It may happen that an unsupported version of libxml2 passes all tests under
certain conditions. This is no reason to assume that it shall work without
problems. If Makefile.PL marks a version of libxml2 as incompatible or broken
it is done for a good reason.

Notes for Microsoft Windows

Thanks to Randy Kobes there is a pre-compiled PPM package available on

Usually it takes a little time to build the package for the latest release.

If you want to build XML::LibXML on Windows from source, you can use the
following instructions contributed by Christopher J. Madsen:

These instructions assume that you already have your system set up to compile
modules that use C components.

First, get the libxml2 binaries from
(currently also available at

You need:


Download the latest version of each. (Each package will probably have a
different version.) When you extract them, you'll get directories named
iconv-VERSION.win32, libxml2-VERSION.win32, and zlib-VERSION.win32, each
containing bin, lib, and include directories.

Combine all the bin, include, and lib directories under c:\Prog\LibXML. (You
can use any directory you prefer; just adjust the instructions accordingly.)

Get the latest version of XML-LibXML from CPAN. Extract it.

Issue these commands in the XML-LibXML-VERSION directory:

>   perl Makefile.PL INC=-Ic:\Prog\LibXML\include LIBS=-Lc:\Prog\LibXML\lib
>   nmake
>   copy c:\Prog\LibXML\bin\*.dll blib\arch\auto\XML\LibXML
>   nmake test
>   nmake install

(Note: Some systems use dmake instead of nmake.)

By copying the libxml2 DLLs to the arch directory, you help avoid conflicts
with other programs you may have installed that use other (possibly
incompatible) versions of those DLLs.

Notes for Mac OS X

Due refactoring the module, XML::LibXML will not run with some earlier versions
of Mac OS X. It appears that this is related to special linker options for that
OS prior to version 10.2.2. Since the developers do not have full access to
this OS, help/ patches from OS X gurus are highly appreciated.

It is confirmed that XML::LibXML builds and runs without problems since Mac OS
X 10.2.6.

Notes for HPUX

XML::LibXML requires libxml2 2.6.16 or later. There may not exist a usable
binary libxml2 package for HPUX and XML::LibXML. If HPUX cc does not compile
libxml2 correctly, you will be forced to recompile perl with gcc (unless you
have already done that).

Additionally I received the following Note from Rozi Kovesdi:

> Here is my report if someone else runs into the same problem:
> Finally I am done with installing all the libraries and XML Perl
> modules
> The combination that worked best for me was:
> gcc
> GNU make
> Most importantly - before trying to install Perl modules that depend on
> libxml2:
> must set SHLIB_PATH  to include  the path to  libxml2 shared library
> assuming that you used the default:
> export  SHLIB=/usr/local/lib
> also, make sure that the config  files have execute permission:
> /usr/local/bin/xml2-config
> /usr/local/bin/xslt-config
> they did not have +x after they were installed by 'make install'
> and it took me a while to realize that this was my problem
> or one can use:
> perl Makefile.PL LIBS='-L/path/to/lib' INC='-I/path/to/include'


For bug reports, please use the CPAN request tracker on

For suggestions etc. you may contact the maintainer directly at "pajas at ufal
dot mff dot cuni dot cz", but in general, it is recommended to use the mailing
list given below.

For suggestions etc., and other issues related to XML::LibXML you may use the
perl XML mailing list (, where most
XML-related Perl modules are discussed. In case of problems you should check
the archives of that list first. Many problems are already discussed there. You
can find the list's archives and subscription options at


Version < 0.98 were maintained by Matt Sergeant

0.98 > Version > 1.49 were maintained by Matt Sergeant and Christian Glahn

Versions >= 1.49 are maintained by Christian Glahn

Versions > 1.56 are co-maintained by Petr Pajas

Versions >= 1.59 are provisionally maintained by Petr Pajas


As XML::LibXML is open source software, help and patches are appreciated. If
you find a bug in the current release, make sure this bug still exists in the
developer version of XML::LibXML. This version can be cloned from its Git
repository. For more information about that, see:

Please consider all regression tests as correct. If any test fails it is most
certainly related to a bug.

If you find documentation bugs, please fix them in the libxml.dbk file, stored
in the docs directory.


The push-parser implementation causes memory leaks.