parser/ExpatParser.php
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.
- Access
- public
- Author
- Andreas Aderhold
- Copyright
- 2001,2002 THYRELL. All rights reserved
- Package
- phing.parser
- Version
- $Id$
\ExpatParser
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.
- Parent(s)
- \AbstractSAXParser
- Access
- public
- Author
- Andreas Aderhold
- Copyright
- 2001,2002 THYRELL. All rights reserved
- Version
- $Id$
Properties
Methods


__construct(
\Reader $reader, string $filename
=
null
)
:
void
Constructs a new ExpatParser object.
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.
Name | Type | Description |
---|---|---|
$reader | \Reader | The Reader Object that is to be read from. |
$filename | string | Filename to read. |
Exception | Description |
---|---|
\Exception | if the given argument is not a PhingFile object |


characters(
resource $parser, string $data
)
:
void
Method that gets invoked when the parser runs over CDATA.
Inherited from: \AbstractSAXParser::characters()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.
Name | Type | Description |
---|---|---|
$parser | resource | php's internal parser handle. |
$data | string | the CDATA |
Exception | Description |
---|---|
\Exception | - Exceptions may be thrown by the Handler |


endElement(
object $parser, string $name
)
:
void
Method that gets invoked when the parser runs over a XML close element.
Inherited from: \AbstractSAXParser::endElement()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.
Name | Type | Description |
---|---|---|
$parser | object | the php's internal parser handle |
$name | string | the closing tag name |
Exception | Description |
---|---|
\Exception | - Exceptions may be thrown by the Handler |


getLocation(
)
:
object
Returns the location object of the current parsed element. It describes the location of the element within the XML file (line, char)
Type | Description |
---|---|
object | the location of the current parser |
- Access
- public


parse(
)
:
int
Starts the parsing process.
Type | Description |
---|---|
int | 1 if the parsing succeeded |
Exception | Description |
---|---|
\ExpatParseException | if something gone wrong during parsing |
\IOException | if XML file can not be accessed |
- Access
- public


parserSetOption(
string $opt, $val
)
:
boolean
Override PHP's parser default settings, created in the constructor.
Name | Type | Description |
---|---|---|
$opt | string | the option to set |
$val |
Type | Description |
---|---|
boolean | true if the option could be set, otherwise false |
Exception | Description |
---|---|
mixed | the value to set |
- Access
- public


setHandler(
\AbstractHandler $obj
)
:
void
Sets the current element handler object for this parser. Usually this is an object using extending "AbstractHandler".
Inherited from: \AbstractSAXParser::setHandler()Name | Type | Description |
---|---|---|
$obj | \AbstractHandler | The handler object. |


startElement(
object $parser, string $name, array $attribs
)
:
void
Method that gets invoked when the parser runs over a XML start element.
Inherited from: \AbstractSAXParser::startElement()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.
Name | Type | Description |
---|---|---|
$parser | object | the php's internal parser handle |
$name | string | the open tag name |
$attribs | array | the tag's attributes if any |
Exception | Description |
---|---|
\Exception | - Exceptions may be thrown by the Handler |