[ Index ]
 

Code source de LifeType 1.2.4

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/class/xml/parser/ -> Parser.php (sommaire)

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

Author: Stig Bakken <ssb@fast.no>
Author: Tomas V.V.Cox <cox@idecnet.com>
Author: Stephan Schmidt <schst@php-tools.net>
Poids: 679 lignes (19 kb)
Inclus ou requis:0 fois
Référencé: 1 fois
Nécessite: 0 fichiers

Définit 2 classes

XML_Parser:: (20 méthodes):
  XML_Parser()
  __construct()
  setMode()
  setHandlerObj()
  _initHandlers()
  _create()
  reset()
  setInputFile()
  setInputString()
  setInput()
  parse()
  _parseString()
  parseString()
  free()
  raiseError()
  funcStartHandler()
  funcEndHandler()
  startHandler()
  endHandler()
  isError()

XML_Parser_Error:: (1 méthode):
  XML_Parser_Error()


Classe: XML_Parser  - X-Ref

\ingroup XML

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
- From revision 1.17, the function names used by the 'func' mode
are in the format "xmltag_$elem", for example: use "xmltag_name"
to handle the <name></name> tags of your xml file.

XML_Parser($srcenc = null, $mode = 'event', $tgtenc = null)   X-Ref
Creates an XML parser.

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

param: string $srcenc source charset encoding, use NULL (default) to use
param: string $mode   how this parser object should work, "event" for
param: string $tgenc  a valid target encoding

__construct($srcenc = null, $mode = 'event', $tgtenc = null)   X-Ref
PHP5 constructor

param: string $srcenc source charset encoding, use NULL (default) to use
param: string $mode   how this parser object should work, "event" for
param: string $tgenc  a valid target encoding

setMode($mode)   X-Ref
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.

param: string          mode, either 'func' or 'event'
return: boolean|object  true on success, PEAR_Error otherwise   

setHandlerObj(&$obj)   X-Ref
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.

param: object      object to handle the events
return: boolean     will always return true

_initHandlers()   X-Ref
Init the element handlers


_create()   X-Ref
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.

return: boolean|object     true on success, PEAR_Error otherwise

reset()   X-Ref
Reset the parser.

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

return: boolean|object     true on success, PEAR_Error otherwise

setInputFile($file)   X-Ref
Sets the input xml file to be parsed

param: string      Filename (full path)
return: resource    fopen handle of the given file

setInputString($data)   X-Ref
XML_Parser::setInputString()

Sets the xml input from a string

param: string $data a string containing the XML document
return: null

setInput($fp)   X-Ref
Sets the file handle to use with parse().

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

param: mixed  $fp  Can be either a resource returned from fopen(),

parse()   X-Ref
Central parsing function.

return: true|object PEAR error     returns true on success, or a PEAR_Error otherwise

_parseString($data, $eof = false)   X-Ref
XML_Parser::_parseString()

param: string $data
param: boolean $eof
return: bool

parseString($data, $eof = false)   X-Ref
XML_Parser::parseString()

Parses a string.

param: string  $data XML data
param: boolean $eof  If set and TRUE, data is the last piece of data sent in this parser
return: Pear Error|true   true on success or a PEAR Error

free()   X-Ref
XML_Parser::free()

Free the internal resources associated with the parser

return: null

raiseError($msg = null, $ecode = 0)   X-Ref
XML_Parser::raiseError()

Trows a XML_Parser_Error and free's the internal resources

param: string  $msg   the error message
param: integer $ecode the error message code
return: XML_Parser_Error

funcStartHandler($xp, $elem, $attribs)   X-Ref
Pas de description

funcEndHandler($xp, $elem)   X-Ref
Pas de description

startHandler($xp, $elem, &$attribs)   X-Ref


endHandler($xp, $elem)   X-Ref


isError( $obj )   X-Ref
Pas de description

Classe: XML_Parser_Error  - X-Ref

error class, replaces PEAR_Error

An instance of this class will be returned
if an error occurs inside XML_Parser.

There are three advantages over using the standard PEAR_Error:
- All messages will be prefixed
- check for XML_Parser error, using is_a( $error, 'XML_Parser_Error' )
- messages can be generated from the xml_parser resource

XML_Parser_Error($msgorparser = 'unknown error', $code = 0, $mode = PEAR_ERROR_RETURN, $level = E_USER_NOTICE)   X-Ref
construct a new error instance

You may either pass a message or an xml_parser resource as first
parameter. If a resource has been passed, the last error that
happened will be retrieved and returned.

param: string|resource     message or parser resource
param: integer             error code
param: integer             error handling
param: integer             error level



Généré le : Mon Nov 26 21:04:15 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics