View on GitHub

LibXML-raku

Raku bindings to the libxml2 native library

[Raku LibXML Project] / [LibXML Module] / Enums

module LibXML::Enums

Native enumerations

Description

The Lib::XML::Enums module exports a large number of libxml2 native enumerations.

All are prefixed XML_*.

These are mostly low-level and encapsulated by LibXML. For example for nodes of type LibXML::Element always have a type of XML_ELEMENT_NODE.

The code attribute of X::LibXML exceptions (see LibXML::ErrorHandling) may be useful, if you wish to detect various libxml errors, for example:

use LibXML;
use LibXML::Enums;

try LibXML.parse: :string("<foo>42</bar>");
with $! -> X::LibXML $err {
    if $err.code == XML_ERR_TAG_NAME_MISMATCH {
        warn "your tags don't match";
    }
    else {
        warn $err;
    }
}

The libxml error documentation lists possible error codes. Enumerations should be defined for all of these.

License

This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0 http://www.perlfoundation.org/artistic_license_2_0.