Moodle  2.2.1
http://www.collinsharper.com
XML_Parser Class Reference
Inheritance diagram for XML_Parser:
Collaboration diagram for XML_Parser:

Public Member Functions

 XML_Parser ($srcenc=null, $mode= 'event', $tgtenc=null)
 __construct ($srcenc=null, $mode= 'event', $tgtenc=null)
 setMode ($mode)
 setHandlerObj (&$obj)
 _initHandlers ()
 _create ()
 reset ()
 setInputFile ($file)
 setInputString ($data)
 setInput ($fp)
 parse ()
 _parseString ($data, $eof=false)
 parseString ($data, $eof=false)
 free ()
raiseError ($msg=null, $ecode=0)
 funcStartHandler ($xp, $elem, $attribs)
 funcEndHandler ($xp, $elem)
 startHandler ($xp, $elem, &$attribs)
 endHandler ($xp, $elem)

Data Fields

 $parser
 $fp
 $folding = true
 $mode
 $handler
 $srcenc
 $tgtenc
 $_handlerObj
 $_validEncodings = array('ISO-8859-1', 'UTF-8', 'US-ASCII')

Detailed Description

Definition at line 116 of file Parser.php.


Constructor & Destructor Documentation

__construct ( srcenc = null,
mode = 'event',
tgtenc = null 
)

PHP5 constructor

Parameters:
string$srcencsource charset encoding, use NULL (default) to use whatever the document specifies
string$modehow this parser object should work, "event" for startelement/endelement-type events, "func" to have it call functions named after elements
string$tgtenca valid target encoding

Definition at line 227 of file Parser.php.

Here is the call graph for this function:

Here is the caller graph for this function:


Member Function Documentation

_create ( )

create the XML parser resource

Has been moved from the constructor to avoid problems with object references.

Furthermore it allows us returning an error if something fails.

NOTE: uses '@' error suppresion in this method

Returns:
bool|PEAR_Error true on success, PEAR_Error otherwise private
See also:
xml_parser_create

Definition at line 349 of file Parser.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Init the element handlers

Returns:
mixed private

set additional handlers for character data, entities, etc.

Reimplemented in XML_Parser_Simple.

Definition at line 294 of file Parser.php.

Here is the call graph for this function:

Here is the caller graph for this function:

_parseString ( data,
eof = false 
)

XML_Parser::_parseString()

Parameters:
string$datadata
bool$eofend-of-file flag
Returns:
bool private
See also:
parseString()

Definition at line 544 of file Parser.php.

Here is the caller graph for this function:

endHandler ( xp,
elem 
)

abstract method signature for End Handler

Parameters:
mixed$xp??
mixed$elem??
Returns:
null

Reimplemented in XML_Parser_Simple, and BasicXmlParser.

Definition at line 696 of file Parser.php.

free ( )

XML_Parser::free()

Free the internal resources associated with the parser

Returns:
null

Definition at line 590 of file Parser.php.

Here is the caller graph for this function:

funcEndHandler ( xp,
elem 
)

derives and calls the End Handler function

Parameters:
mixed$xp??
mixed$elem??
Returns:
void

Definition at line 655 of file Parser.php.

funcStartHandler ( xp,
elem,
attribs 
)

derives and calls the Start Handler function

Parameters:
mixed$xp??
mixed$elem??
mixed$attribs??
Returns:
void

Definition at line 632 of file Parser.php.

parse ( )

Central parsing function.

Returns:
bool|PEAR_Error returns true on success, or a PEAR_Error otherwise public

reset the parser

Definition at line 502 of file Parser.php.

Here is the call graph for this function:

parseString ( data,
eof = false 
)

XML_Parser::parseString()

Parses a string.

Parameters:
string$dataXML data
boolean$eofIf set and TRUE, data is the last piece of data sent in this parser
Returns:
bool|PEAR_Error true on success or a PEAR Error
Exceptions:
XML_Parser_Error
See also:
_parseString()

Definition at line 565 of file Parser.php.

Here is the call graph for this function:

& raiseError ( msg = null,
ecode = 0 
)

XML_Parser::raiseError()

Throws a XML_Parser_Error

Parameters:
string$msgthe error message
integer$ecodethe error message code
Returns:
XML_Parser_Error reference to the error object

Definition at line 613 of file Parser.php.

Here is the caller graph for this function:

reset ( )

Reset the parser.

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

public

Returns:
boolean|object true on success, PEAR_Error otherwise

Reimplemented in XML_Parser_Simple.

Definition at line 393 of file Parser.php.

Here is the call graph for this function:

Here is the caller graph for this function:

setHandlerObj ( &$  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_Parser assumes that you extend this class and handle the events in $this.

Parameters:
object&$objobject to handle the events
Returns:
boolean will always return true public
Since:
v1.2.0beta3

Definition at line 282 of file Parser.php.

setInput ( fp)

Sets the file handle to use with parse().

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

Parameters:
mixed$fpCan be either a resource returned from fopen(), a URL, a local filename or a string.
Returns:
mixed public
See also:
parse() setInputString(), setInputFile()

Definition at line 472 of file Parser.php.

Here is the call graph for this function:

setInputFile ( file)

Sets the input xml file to be parsed

Parameters:
string$fileFilename (full path)
Returns:
resource fopen handle of the given file public
Exceptions:
XML_Parser_Error
See also:
setInput(), setInputString(), parse()

check, if file is a remote file

Definition at line 415 of file Parser.php.

Here is the call graph for this function:

Here is the caller graph for this function:

setInputString ( data)

XML_Parser::setInputString()

Sets the xml input from a string

Parameters:
string$dataa string containing the XML document
Returns:
null

Definition at line 449 of file Parser.php.

setMode ( 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.

Parameters:
string$modemode, either 'func' or 'event'
Returns:
boolean|object true on success, PEAR_Error otherwise public

Definition at line 255 of file Parser.php.

Here is the call graph for this function:

startHandler ( xp,
elem,
&$  attribs 
)

abstract method signature for Start Handler

Parameters:
mixed$xp??
mixed$elem??
mixed&$attribs??
Returns:
null

Reimplemented in XML_Parser_Simple.

Definition at line 679 of file Parser.php.

XML_Parser ( srcenc = null,
mode = 'event',
tgtenc = null 
)

Creates an XML parser.

This is needed for PHP4 compatibility, it will call the constructor, when a new instance is created.

Parameters:
string$srcencsource charset encoding, use NULL (default) to use whatever the document specifies
string$modehow this parser object should work, "event" for startelement/endelement-type events, "func" to have it call functions named after elements
string$tgtenca valid target encoding

Definition at line 210 of file Parser.php.

Here is the call graph for this function:

Here is the caller graph for this function:


Field Documentation

$_handlerObj

Definition at line 185 of file Parser.php.

$_validEncodings = array('ISO-8859-1', 'UTF-8', 'US-ASCII')

Definition at line 192 of file Parser.php.

$folding = true

Definition at line 143 of file Parser.php.

$fp

Definition at line 133 of file Parser.php.

$handler
Initial value:
 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'
    )

Reimplemented in XML_Parser_Simple.

Definition at line 157 of file Parser.php.

$mode

Definition at line 150 of file Parser.php.

$parser

Definition at line 126 of file Parser.php.

$srcenc

Definition at line 171 of file Parser.php.

$tgtenc

Definition at line 178 of file Parser.php.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations