This class is a wrapper for the PHP's internal expat parser.

It takes an XML file represented by a abstract path name, and starts parsing the file and calling the different "trap" methods inherited from the AbstractParser class.

Those methods then invoke the represenatative methods in the registered handler classes.

author | Andreas Aderhold
copyright | 2001,2002 THYRELL. All rights reserved
version | $Id$
access | public
package | phing.parser

### Methods

## Constructs a new ExpatParser object.

    __construct(\Reader $reader, string $filename)

The constructor accepts a PhingFile object that represents the filename for the file to be parsed. It sets up php's internal expat parser and options.

### Parameters

#### $reader

`\Reader`

The Reader Object that is to be read from.

#### $filename

`string`

Filename to read.

### Exceptions

`\Exception` | if the given argument is not a PhingFile object

## Method that gets invoked when the parser runs over CDATA.

    characters(resource $parser, string $data)

Inherited

This method is called by PHP's internal parser functions and registered in the actual parser implementation.

It gives control to the current active handler object by calling the

    characters()

method. That processes the given CDATA.

inherited_from | \AbstractSAXParser::characters()

### Parameters

#### $parser

`resource`

php's internal parser handle.

#### $data

`string`

the CDATA

### Exceptions

`\Exception` | - Exceptions may be thrown by the Handler

## Method that gets invoked when the parser runs over a XML close element.

    endElement(object $parser, string $name)

Inherited

This method is called by PHP's internal parser funcitons and registered in the actual parser implementation.

It gives control to the current active handler object by calling the

    endElement()

method.

inherited_from | \AbstractSAXParser::endElement()

### Parameters

#### $parser

`object`

the php's internal parser handle

#### $name

`string`

the closing tag name

### Exceptions

`\Exception` | - Exceptions may be thrown by the Handler

## Returns the location object of the current parsed element.

    getLocation() : object

It describes the location of the element within the XML file (line, char)

access | public

### Returns

`object`the location of the current parser

## Starts the parsing process.

    parse() : int

This method needs to be implemented by the child classt that utilizes the concrete parser

access | public

### Exceptions

`\ExpatParseException` | if something gone wrong during parsing
`\IOException` | if XML file can not be accessed

### Returns

`int`1 if the parsing succeeded

## Override PHP's parser default settings, created in the constructor.

    parserSetOption(string $opt, $val) : boolean

Must be implemented by the parser class if it should be used.

access | public

### Parameters

#### $opt

`string`

the option to set

#### $val

### Exceptions

`mixed` | the value to set

### Returns

`boolean`true if the option could be set, otherwise false

## Sets the current element handler object for this parser.

    setHandler(\AbstractHandler $obj)

Inherited

Usually this is an object using extending "AbstractHandler".

inherited_from | \AbstractSAXParser::setHandler()

### Parameters

#### $obj

`\AbstractHandler`

The handler object.

## Method that gets invoked when the parser runs over a XML start element.

    startElement(object $parser, string $name, array $attribs)

Inherited

This method is called by PHP's internal parser functions and registered in the actual parser implementation. It gives control to the current active handler object by calling the

    startElement()

method.

inherited_from | \AbstractSAXParser::startElement()

### Parameters

#### $parser

`object`

the php's internal parser handle

#### $name

`string`

the open tag name

#### $attribs

`array`

the tag's attributes if any

### Exceptions

`\Exception` | - Exceptions may be thrown by the Handler

### Properties

##

    $handler

Inherited

inherited_from | \AbstractSAXParser::$$handler

##

    $buffer

##

    $error_string

##

    $file

##

    $line

## Current cursor pos in XML file.

    $location : \Location

##

    $parser : resource

##

    $reader : \Reader