Help language development. Donate to The Perl Foundation

LibXML cpan:WARRINGD last updated on 2020-08-17
[![Build Status](](


LibXML - Raku bindings to the libxml2 native library


    use LibXML::Document;
    my LibXML::Document $doc .=  parse: :string('<Hello/>');
    $doc.root.nodeValue = 'World!';
    say $doc.Str;
    # <?xml version="1.0" encoding="UTF-8"?>
    # <Hello>World!</Hello>
    say $doc<Hello>;
    # <Hello>World!</Hello>

    my Version $library-version = LibXML.version;
    my Version $module-version = LibXML.^ver;


This module is an interface to libxml2, providing XML and HTML parsers with DOM, SAX and XMLReader interfaces, a large subset of DOM Layer 3 interface and a XML::XPath-like interface to XPath API of libxml2.

For further information, please check the following documentation:

DOM Objects

The nodes in the Document Object Model (DOM) are represented by the following classes (most of which "inherit" from [LibXML::Node](

  * [LibXML::Document]( - LibXML DOM attribute class

  * [LibXML::Attr]( - LibXML attribute class

  * [LibXML::CDATA]( - LibXML class for DOM CDATA sections

  * [LibXML::Comment]( - LibXML class for comment DOM nodes

  * [LibXML::DocumentFragment]( - LibXML's DOM L2 Document Fragment implementation

  * [LibXML::Dtd]( - LibXML frontend for DTD validation

  * [LibXML::Element]( - LibXML class for element nodes

  * [LibXML::Namespace]( - LibXML DOM namespaces (Inherits from [LibXML::Item](

  * [LibXML::Node]( - LibXML DOM abstract base node class

  * [LibXML::Text]( - LibXML text node class

  * [LibXML::PI]( - LibXML DOM processing instruction nodes

Container/Mapping classes

  * [LibXML::Attr::Map]( - LibXML DOM attribute map class

  * [LibXML::Node::List]( - Sibling Node Lists

  * [LibXML::Node::Set]( - XPath Node Sets

  * [LibXML::HashMap]( - LibXML Hash Bindings


  * [LibXML::Parser]( - LibXML Parser bindings

  * [LibXML::PushParser]( - LibXML Push Parser bindings

  * [LibXML::Reader]( - LibXML Reader (pull parser) bindings

XPath and Searching

  * [LibXML::XPath::Expression]( - XPath Compiled Expressions

  * [LibXML::XPath::Context]( - XPath Evaluation Contexts

  * [LibXML::Pattern]( - LibXML Patterns

  * [LibXML::RegExp]( - LibXML Regular Expression bindings


  * [LibXML::Schema]( - LibXML schema validation class

  * [LibXML::RelaxNG]( - LibXML RelaxNG validation class


  * [LibXML::Config]( - LibXML global configuration

  * [LibXML::Enums]( - LibXML XML_* enumerated constants

  * [LibXML::Raw]( - LibXML native interface

  * [LibXML::ErrorHandling]( - LibXML class for Error handling

  * [LibXML::InputCallback]( - LibXML class for Input callback handling


This module requires the libxml2 library to be installed. Please follow the instructions below based on your platform:

Debian Linux

sudo apt-get install libxml2-dev

Mac OS X

brew update
brew install libxml2


This Raku module:

  * is based on the Perl 5 XML::LibXML module; in particular, the test suite, selected XS and C code and documentation.

  * derives SelectorQuery() and SelectorQueryAll() methods from the Perl 5 XML::LibXML::QuerySelector module.

  * also draws on an earlier attempt at a Perl 6 (nee Raku) port (XML::LibXML).

With thanks to: Christian Glahn, Ilya Martynov, Matt Sergeant, Petr Pajas, Shlomi Fish, Toby Inkster, Tobias Leich, Xliff, and others.




2001-2007, Ltd.

2002-2006, Christian Glahn.

2006-2009, Petr Pajas.


This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0 [](