XML_Parser2
[ class tree: XML_Parser2 ] [ index: XML_Parser2 ] [ all elements ]

Class: XML_Parser2

Source Location: /XML_Parser2-0.1.0/XML/Parser2.php

Class Overview


XML Parser class.


Author(s):

Version:

  • Release: @package_version@

Copyright:

  • 2002-2008 The PHP Group

Variables

Methods


Child classes:

XML Parser class.
XML_Parser2_Simple
Simple XML parser class.

Inherited Variables

Inherited Methods


Class Details

[line 111]
XML Parser class.

This is an XML parser based on PHP's "xml" extension, based on the bundled expat library.

Notes:

  • It requires PHP 4.0.4pl1 or greater
  • different parsing modes

  • Author: Stig Bakken <ssb@fast.no>
  • Author: Stephan Schmidt <schst@php.net>
  • Author: Tomas V.V.Cox <cox@idecnet.com>
  • Version: Release: @package_version@
  • Copyright: 2002-2008 The PHP Group
  • Link: http://pear.php.net/package/XML_Parser2
  • Todo: create XML_Parser2_Pull
  • Todo: Tests that need to be made:
    • mixing character encodings
    • a test using all expat handlers
    • options (folding, output charset)
  • Todo: create XML_Parser2_Namespace to parse documents with namespaces
  • License: New BSD License


[ Top ]


Class Variables

$folding =  true

[line 138]

Whether to do case folding

If set to true, all tag and attribute names will be converted to UPPER CASE.


Type:   boolean


[ Top ]

$fp =

[line 128]

File handle if parsing from a file

Type:   resource


[ Top ]

$handler = array(
        'character_data_handler'            => 'cdataHandler',
        'default_handler'                   => 'defaultHandler',
        'processing_instruction_handler'    => 'piHandler',
        'unparsed_entity_decl_handler'      => 'unparsedHandler',
        'notation_decl_handler'             => 'notationHandler',
        'external_entity_ref_handler'       => 'entityrefHandler'
    )

[line 152]

Mapping from expat handler function to class method.

Type:   array


[ Top ]

$mode =

[line 145]

Mode of operation, one of "event" or "func"

Type:   string


[ Top ]

$parser =

[line 121]

XML parser handle

Type:   resource


[ Top ]

$srcenc =

[line 166]

source encoding

Type:   string


[ Top ]

$tgtenc =

[line 173]

target encoding

Type:   string


[ Top ]



Method Detail

__construct (Constructor)   [line 203]

XML_Parser2 __construct( [string $srcenc = null], [string $mode = 'event'], [string $tgtenc = null])

PHP5 constructor

Parameters:

string   $srcenc   —  source charset encoding, use NULL (default) to use whatever the document specifies
string   $mode   —  how this parser object should work, "event" for startelement/endelement-type events, "func" to have it call functions named after elements
string   $tgtenc   —  a valid target encoding

[ Top ]

endHandler   [line 638]

null endHandler( mixed $xp, mixed $elem)

abstract method signature for End Handler
  • Abstract:

Parameters:

mixed   $xp   —  ??
mixed   $elem   —  ??

[ Top ]

free   [line 549]

null free( )

XML_Parser2::free()

Free the internal resources associated with the parser


[ Top ]

funcEndHandler   [line 597]

void funcEndHandler( mixed $xp, mixed $elem)

derives and calls the End Handler function

Parameters:

mixed   $xp   —  ??
mixed   $elem   —  ??

[ Top ]

funcStartHandler   [line 574]

void funcStartHandler( mixed $xp, mixed $elem, mixed $attribs)

derives and calls the Start Handler function

Parameters:

mixed   $xp   —  ??
mixed   $elem   —  ??
mixed   $attribs   —  ??

[ Top ]

parse   [line 470]

bool|PEAR_Error parse( )

Central parsing function.
  • Return: returns true on success, or a PEAR_Error otherwise
  • Access: public

[ Top ]

parseString   [line 526]

bool|PEAR_Error parseString( string $data, [boolean $eof = false])

XML_Parser2::parseString()

Parses a string.

  • Return: true on success or a PEAR Error
  • See: _parseString()
  • Throws: XML_Parser2_Error

Parameters:

string   $data   —  XML data
boolean   $eof   —  If set and TRUE, data is the last piece of data sent in this parser

[ Top ]

reset   [line 364]

boolean|object reset( )

Reset the parser.

This allows you to use one parser instance to parse multiple XML documents.

  • Return: true on success, PEAR_Error otherwise
  • Access: public

Overridden in child classes as:

XML_Parser2_Simple::reset()
Reset the parser.

[ Top ]

setHandlerObj   [line 256]

boolean setHandlerObj( object $obj)

Sets the object, that will handle the XML events

This allows you to create a handler object independent of the parser object that you are using and easily switch the underlying parser.

If no object will be set, XML_Parser2 assumes that you extend this class and handle the events in $this.

  • Return: will always return true
  • Since: v1.2.0beta3
  • Access: public

Parameters:

object   $obj   —  object to handle the events

[ Top ]

setInput   [line 440]

mixed setInput( mixed $fp)

Sets the file handle to use with parse().

You should use setInputFile() or setInputString() if you pass a string


Parameters:

mixed   $fp   —  Can be either a resource returned from fopen(), a URL, a local filename or a string.

[ Top ]

setInputFile   [line 383]

resource setInputFile( string $file)

Sets the input xml file to be parsed

Parameters:

string   $file   —  Filename (full path)

[ Top ]

setInputString   [line 417]

null setInputString( string $data)

XML_Parser2::setInputString()

Sets the xml input from a string


Parameters:

string   $data   —  a string containing the XML document

[ Top ]

setMode   [line 229]

boolean|object setMode( string $mode)

Sets the mode of the parser.

Possible modes are:

  • func
  • event
You can set the mode using the second parameter in the constructor.

This method is only needed, when switching to a new mode at a later point.

  • Return: true on success, PEAR_Error otherwise
  • Access: public

Parameters:

string   $mode   —  mode, either 'func' or 'event'

[ Top ]

startHandler   [line 621]

null startHandler( mixed $xp, mixed $elem, mixed $attribs)

abstract method signature for Start Handler
  • Abstract:

Parameters:

mixed   $xp   —  ??
mixed   $elem   —  ??
mixed   $attribs   —  ??

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:47:54 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.