# perldoc > XML::Handler::BuildDOM

---
type: CommandReference
command: XML::Handler::BuildDOM
mode: perldoc
section: ""
source: perldoc
---

## Quick Reference
- `XML::Handler::BuildDOM->new(KeepCDATA => 1)` — Create handler with CDATA preservation
- `XML::Parser::PerlSAX->new(Handler => $handler)` — Attach handler to parser
- `$parser->parsefile("file.xml")` — Parse XML and return `XML::DOM::Document`
- `Document => $doc` — Attach to an existing document
- `Element => $elem` — Set insertion point (default: Document)
- `DocType => $doctype` — Attach an existing document type

## Name
`XML::Handler::BuildDOM` — PerlSAX handler that creates `XML::DOM` document structures

## Synopsis
perl
use XML::Handler::BuildDOM;
use XML::Parser::PerlSAX;

my $handler = XML::Handler::BuildDOM->new(KeepCDATA => 1);
my $parser = XML::Parser::PerlSAX->new(Handler => $handler);

my $doc = $parser->parsefile("file.xml");
## Description
`XML::Handler::BuildDOM` creates `XML::DOM::Document` structures from PerlSAX events. Formerly known as `XML::PerlSAX::DOM` (prior to libxml-enno 1.0.1).

### Constructor Options
- `KeepCDATA => 1` — If set to 0 (default), CDATASections are converted to regular text. Set to 1 to preserve them.
- `Document => $doc` — If undefined, `start_document` extracts it from `Element` or `DocType` (if set), otherwise creates a new `XML::DOM::Document`.
- `Element => $elem` — If undefined, set to `Document`. This is the insertion point (parent) for nodes defined by subsequent callbacks.
- `DocType => $doctype` — If undefined, `start_document` extracts it from `Document` (if possible). Otherwise adds a new `XML::DOM::DocumentType` to the document.

## See Also
- [XML::DOM](http://localhost/phpMan.php/perldoc/XML::DOM)
- [XML::Parser::PerlSAX](http://localhost/phpMan.php/perldoc/XML::Parser::PerlSAX)
- [XML::PerlSAX::DOM](http://localhost/phpMan.php/perldoc/XML::PerlSAX::DOM) (old name)