XML_Parser
[ class tree: XML_Parser ] [ index: XML_Parser ] [ all elements ]
Packages:
XML_Parser


Classes:
XML_Parser
XML_Parser_Error
XML_Parser_Simple
XML_Parser
myParser
myParser2
Files:
Parser.php
Simple.php

subpackage Examples
xml_parser_file.php
xml_parser_funcmode.php
xml_parser_handler.php
xml_parser_simple1.php
xml_parser_simple2.php
xml_parser_simple_handler.php

Class: XML_Parser

Source Location: /XML_Parser-1.3.5/XML/Parser.php

Class Overview

PEAR
 |
 --XML_Parser

XML Parser class.


Author(s):

Version:

  • Release: @package_version@

Copyright:

  • 2002-2008 The PHP Group

Variables

Methods


Child classes:

XML Parser class.
XML_Parser_Simple
Simple XML parser class.

Inherited Variables

Inherited Methods


Class Details

[line 116]
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_Parser
  • Todo: create XML_Parser_Pull
  • Todo: Tests that need to be made:
    • mixing character encodings
    • a test using all expat handlers
    • options (folding, output charset)
  • Todo: create XML_Parser_Namespace to parse documents with namespaces
  • License: New BSD License


[ Top ]


Class Variables

$folding = true

[line 143]

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 133]

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 157]

Mapping from expat handler function to class method.

Type: array


[ Top ]

$mode =

[line 150]

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

Type: string


[ Top ]

$parser =

[line 126]

XML parser handle

Type: resource


[ Top ]

$srcenc =

[line 171]

source encoding

Type: string


[ Top ]

$tgtenc =

[line 178]

target encoding

Type: string


[ Top ]



Method Detail

__construct (Constructor) [line 207]

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

PHP5 constructor

Overridden in child classes as:

XML_Parser_Simple::__construct()
Creates an XML parser.

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 676]

null endHandler( mixed $xp, mixed $elem)

abstract method signature for End Handler
  • Abstract:

Parameters:

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

[ Top ]

free [line 570]

null free( )

XML_Parser::free()

Free the internal resources associated with the parser


[ Top ]

funcEndHandler [line 635]

void funcEndHandler( mixed $xp, mixed $elem)

derives and calls the End Handler function

Parameters:

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

[ Top ]

funcStartHandler [line 612]

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 482]

bool|PEAR_Error parse( )

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

[ Top ]

parseString [line 545]

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

XML_Parser::parseString()

Parses a string.

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

Parameters:

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

[ Top ]

raiseError [line 593]

XML_Parser_Error raiseError( [string $msg = null], [integer $ecode = 0])

XML_Parser::raiseError()

Throws a XML_Parser_Error

  • Return: reference to the error object

Parameters:

string $msg — the error message
integer $ecode — the error message code

[ Top ]

reset [line 373]

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_Parser_Simple::reset()
Reset the parser.

[ Top ]

setHandlerObj [line 262]

boolean setHandlerObj( $obj, 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_Parser 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
$obj

[ Top ]

setInput [line 452]

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 395]

resource setInputFile( string $file)

Sets the input xml file to be parsed

Parameters:

string $file — Filename (full path)

[ Top ]

setInputString [line 429]

null setInputString( string $data)

XML_Parser::setInputString()

Sets the xml input from a string


Parameters:

string $data — a string containing the XML document

[ Top ]

setMode [line 235]

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 659]

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 2019年3月11日 16:03:06 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.

AltStyle によって変換されたページ (->オリジナル) /