---
name: "XML::LibXML::SAX::Parser"
section: "3pm"
platform: "linux"
package: "libxml-libxml-perl"
version: "1.31-2"
release: "Debian 3.0 (Woody)"
platforms: ["linux"]
url: "https://new.carta.tech/XML::LibXML::SAX::Parser"
---

# XML::LibXML::SAX::Parser(3pm)

LibXML DOM based SAX Parser

## NAME

XML::LibXML::SAX::Parser - LibXML DOM based SAX Parser

## SYNOPSIS

```
  my $handler = MySAXHandler->new();
  my $parser = XML::LibXML::SAX::Parser->new(Handler => $handler);
  $parser->parse_uri("foo.xml");
```

## DESCRIPTION

This class allows you to generate SAX2 events using LibXML. Note that this is **not** a stream based parser, instead it parses documents into a DOM and traverses the DOM tree. The reason being that libxml2's stream based parsing is extremely primitive, and would require an extreme amount of work to allow SAX2 parsing in a stream manner.

## API

The API is exactly the same as any other Perl SAX2 parser. See XML::SAX::Intro for details.

Aside from the regular parsing methods, you can access the DOM tree traverser directly, using the *generate()* method:

```
  my $parser = XML::LibXML::SAX::Parser->new(...);
  $parser->generate($dom_tree);
```

This is useful for serializing DOM trees, for example that you might have done prior processing on, or that you have as a result of XSLT processing.
