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

Class: XML_Parser_Simple

Source Location: /XML_Parser-1.2.4/Parser/Simple.php

Class Overview

PEAR
   |
   --XML_Parser
      |
      --XML_Parser_Simple

Simple XML parser class.


Author(s):

Variables

Methods


Child classes:

Simple XML parser class.
myParser2
Simple XML parser class.

Inherited Variables

Inherited Methods

Class: XML_Parser

XML_Parser::XML_Parser()
Creates an XML parser.
XML_Parser::endHandler()
XML_Parser::free()
XML_Parser::free()
XML_Parser::funcEndHandler()
XML_Parser::funcStartHandler()
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()

Class Details

[line 79]
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
3 class myParser extends XML_Parser_Simple
4 {
5 function myParser()
6 {
7 $this->XML_Parser_Simple();
8 }
9
10 function handleElement($name, $attribs, $data)
11 {
12 printf('handle %s<br>', $name);
13 }
14 }
15
16 $p = &new myParser();
17
18 $result = $p->setInputFile('myDoc.xml');
19 $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 110]

Mapping from expat handler function to class method.

Type:   array
Overrides:   Array


[ Top ]



Method Detail

XML_Parser_Simple (Constructor)   [line 131]

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

Creates an XML parser.

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


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   $tgenc     a valid target encoding

[ Top ]

addToData   [line 288]

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

integer getCurrentDepth( )

get the current tag depth

The root tag is in depth 0.

  • Access: public

[ Top ]

handleElement   [line 262]

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

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 Mon, 11 Apr 2005 15:11:19 -0400 by phpDocumentor 1.2.3. PEAR Logo Copyright © PHP Group 2004.