PHP 클래스 XML_Parser

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 tags of your xml file.
저자: Stig Bakken ([email protected])
저자: Tomas V.V.Cox ([email protected])
저자: Stephan Schmidt ([email protected])
상속: extends PEAR
파일 보기 프로젝트 열기: sourcefabric/newscoop 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$_handlerObj object handler object
$_validEncodings array valid encodings
$folding boolean If set to true, all tag and attribute names will be converted to UPPER CASE.
$fp resource File handle if parsing from a file
$handler array Mapping from expat handler function to class method.
$mode string Mode of operation, one of "event" or "func"
$parser resource XML parser handle
$srcenc string source encoding
$tgtenc string target encoding

공개 메소드들

메소드 설명
XML_Parser ( string $srcenc = null, string $mode = 'event', string $tgtenc = null ) Creates an XML parser.
__construct ( string $srcenc = null, string $mode = 'event', string $tgtenc = null ) PHP5 constructor
_create ( ) : boolean | PEAR_Error create the XML parser resource
_initHandlers ( ) : mixed Init the element handlers
_parseString ( string $data, boolean $eof = false ) : boolean XML_Parser::_parseString()
endHandler ( mixed $xp, mixed $elem ) : null abstract method signature for End Handler
free ( ) : null XML_Parser::free()
funcEndHandler ( mixed $xp, mixed $elem ) : void derives and calls the End Handler function
funcStartHandler ( mixed $xp, mixed $elem, mixed $attribs ) : void derives and calls the Start Handler function
parse ( ) : boolean | PEAR_Error Central parsing function.
parseString ( string $data, boolean $eof = false ) : boolean | PEAR_Error XML_Parser::parseString()
raiseError ( $message = NULL, integer $ecode = NULL, $mode = NULL, $options = NULL, $userinfo = NULL, $error_class = NULL, $skipmsg = false ) : XML_Parser_Error XML_Parser::raiseError()
reset ( ) : boolean | object Reset the parser.
setHandlerObj ( &$obj ) : boolean Sets the object, that will handle the XML events
setInput ( mixed $fp ) : mixed Sets the file handle to use with parse().
setInputFile ( string $file ) : resource Sets the input xml file to be parsed
setInputString ( string $data ) : null XML_Parser::setInputString()
setMode ( string $mode ) : boolean | object Sets the mode of the parser.
startHandler ( mixed $xp, mixed $elem, &$attribs ) : null abstract method signature for Start Handler

메소드 상세

XML_Parser() 공개 메소드

This is needed for PHP4 compatibility, it will call the constructor, when a new instance is created.
public XML_Parser ( string $srcenc = null, string $mode = 'event', string $tgtenc = null )
$srcenc string source charset encoding, use NULL (default) to use whatever the document specifies
$mode string how this parser object should work, "event" for startelement/endelement-type events, "func" to have it call functions named after elements
$tgtenc string a valid target encoding

__construct() 공개 메소드

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

_create() 공개 메소드

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
또한 보기: xml_parser_create
public _create ( ) : boolean | PEAR_Error
리턴 boolean | PEAR_Error true on success, PEAR_Error otherwise

_initHandlers() 공개 메소드

Init the element handlers
public _initHandlers ( ) : mixed
리턴 mixed

_parseString() 공개 메소드

XML_Parser::_parseString()
또한 보기: parseString()
public _parseString ( string $data, boolean $eof = false ) : boolean
$data string data
$eof boolean end-of-file flag
리턴 boolean

endHandler() 공개 메소드

abstract method signature for End Handler
public endHandler ( mixed $xp, mixed $elem ) : null
$xp mixed ??
$elem mixed ??
리턴 null

free() 공개 메소드

Free the internal resources associated with the parser
public free ( ) : null
리턴 null

funcEndHandler() 공개 메소드

derives and calls the End Handler function
public funcEndHandler ( mixed $xp, mixed $elem ) : void
$xp mixed ??
$elem mixed ??
리턴 void

funcStartHandler() 공개 메소드

derives and calls the Start Handler function
public funcStartHandler ( mixed $xp, mixed $elem, mixed $attribs ) : void
$xp mixed ??
$elem mixed ??
$attribs mixed ??
리턴 void

parse() 공개 메소드

Central parsing function.
public parse ( ) : boolean | PEAR_Error
리턴 boolean | PEAR_Error returns true on success, or a PEAR_Error otherwise

parseString() 공개 메소드

Parses a string.
또한 보기: _parseString()
public parseString ( string $data, boolean $eof = false ) : boolean | PEAR_Error
$data string XML data
$eof boolean If set and TRUE, data is the last piece of data sent in this parser
리턴 boolean | PEAR_Error true on success or a PEAR Error

raiseError() 공개 메소드

Throws a XML_Parser_Error
public raiseError ( $message = NULL, integer $ecode = NULL, $mode = NULL, $options = NULL, $userinfo = NULL, $error_class = NULL, $skipmsg = false ) : XML_Parser_Error
$ecode integer the error message code
리턴 XML_Parser_Error reference to the error object

reset() 공개 메소드

This allows you to use one parser instance to parse multiple XML documents.
public reset ( ) : boolean | object
리턴 boolean | object true on success, PEAR_Error otherwise

setHandlerObj() 공개 메소드

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.
public setHandlerObj ( &$obj ) : boolean
리턴 boolean will always return true

setInput() 공개 메소드

You should use setInputFile() or setInputString() if you pass a string
또한 보기: parse()
public setInput ( mixed $fp ) : mixed
$fp mixed Can be either a resource returned from fopen(), a URL, a local filename or a string.
리턴 mixed

setInputFile() 공개 메소드

Sets the input xml file to be parsed
public setInputFile ( string $file ) : resource
$file string Filename (full path)
리턴 resource fopen handle of the given file

setInputString() 공개 메소드

Sets the xml input from a string
public setInputString ( string $data ) : null
$data string a string containing the XML document
리턴 null

setMode() 공개 메소드

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.
public setMode ( string $mode ) : boolean | object
$mode string mode, either 'func' or 'event'
리턴 boolean | object true on success, PEAR_Error otherwise

startHandler() 공개 메소드

abstract method signature for Start Handler
public startHandler ( mixed $xp, mixed $elem, &$attribs ) : null
$xp mixed ??
$elem mixed ??
리턴 null

프로퍼티 상세

$_handlerObj 공개적으로 프로퍼티

handler object
public object $_handlerObj
리턴 object

$_validEncodings 공개적으로 프로퍼티

valid encodings
public array $_validEncodings
리턴 array

$folding 공개적으로 프로퍼티

If set to true, all tag and attribute names will be converted to UPPER CASE.
public bool $folding
리턴 boolean

$fp 공개적으로 프로퍼티

File handle if parsing from a file
public resource $fp
리턴 resource

$handler 공개적으로 프로퍼티

Mapping from expat handler function to class method.
public array $handler
리턴 array

$mode 공개적으로 프로퍼티

Mode of operation, one of "event" or "func"
public string $mode
리턴 string

$parser 공개적으로 프로퍼티

XML parser handle
또한 보기: xml_parser_create()
public resource $parser
리턴 resource

$srcenc 공개적으로 프로퍼티

source encoding
public string $srcenc
리턴 string

$tgtenc 공개적으로 프로퍼티

target encoding
public string $tgtenc
리턴 string