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_Simple

Source Location: /XML_Parser-1.3.8/XML/Parser/Simple.php

Class Overview

PEAR
 |
 --XML_Parser
 |
 --XML_Parser_Simple

Simple XML parser class.


Author(s):

Version:

  • Release: @package_version@

Copyright:

  • 2004-2008 The PHP Group

Variables

Methods


Child classes:

Simple XML parser class.
myParser2
Simple XML parser class.

Inherited Variables

Class: XML_Parser

XML_Parser::$folding
XML_Parser::$fp
XML_Parser::$mode
XML_Parser::$parser
XML_Parser::$srcenc
XML_Parser::$tgtenc

Inherited Methods

Class: XML_Parser

XML_Parser::__construct()
PHP5 constructor
XML_Parser::endHandler()
abstract method signature for End Handler
XML_Parser::free()
XML_Parser::free()
XML_Parser::funcEndHandler()
derives and calls the End Handler function
XML_Parser::funcStartHandler()
derives and calls the Start Handler function
XML_Parser::parse()
Central parsing function.
XML_Parser::parseString()
XML_Parser::parseString()
XML_Parser::raiseError()
XML_Parser::raiseError()
XML_Parser::reset()
Reset the parser.
XML_Parser::setHandlerObj()
Sets the object, that will handle the XML events
XML_Parser::setInput()
Sets the file handle to use with parse().
XML_Parser::setInputFile()
Sets the input xml file to be parsed
XML_Parser::setInputString()
XML_Parser::setInputString()
XML_Parser::setMode()
Sets the mode of the parser.
XML_Parser::startHandler()
abstract method signature for Start Handler

Class Details

[line 96]
Simple XML parser class.

This class is a simplified version of XML_Parser. In most XML applications the real action is executed, when a closing tag is found.

XML_Parser_Simple allows you to just implement one callback for each tag that will receive the tag with its attributes and CData.

  1. require_once '../Parser/Simple.php';
  2. class myParser extends XML_Parser_Simple
  3. {
  4. function myParser ()
  5. {
  6. $this->XML_Parser_Simple();
  7. }
  8. function handleElement($name, $attribs, $data)
  9. {
  10. printf ('handle %s<br>', $name);
  11. }
  12. }
  13. $p = new myParser ();
  14. $result = $p->setInputFile ('myDoc.xml');
  15. $result = $p->parse ();



[ Top ]


Class Variables

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

[line 127]

Mapping from expat handler function to class method.

Type: array
Overrides: Array


[ Top ]



Method Detail

__construct (Constructor) [line 148]

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

Creates an XML parser.

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


Overrides XML_Parser::__construct() (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 handleElement(), "func" to have it call functions named after elements (handleElement_$name())
string $tgtenc — a valid target encoding

[ Top ]

addToData [line 321]

void addToData( string $data)

add some string to the current ddata.

This is commonly needed, when a document is parsed recursively.

  • Access: public

Parameters:

string $data — data to add

[ Top ]

getCurrentDepth [line 306]

integer getCurrentDepth( )

get the current tag depth

The root tag is in depth 0.

  • Access: public

[ Top ]

handleElement [line 294]

void handleElement( string $name, array $attribs, string $data)

handle a tag

Implement this in your parser

  • Abstract:
  • Access: public

Parameters:

string $name — element name
array $attribs — attributes
string $data — character data

[ Top ]

reset [line 195]

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

Overrides XML_Parser::reset() (Reset the parser.)
[ Top ]


Documentation generated on 2019年4月10日 14:24:06 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.

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