XML_HTMLSax3 (Constructor) [line 484]
XML_HTMLSax3 XML_HTMLSax3(
)
|
|
Constructs XML_HTMLSax3 selecting concrete StateParser subclass
depending on PHP version being used as well as setting the default NullHandler for all callbacks
Example:
$myHandler = & new MyHandler();
$parser = new XML_HTMLSax3();
$parser->set_object($myHandler);
$parser->set_option('XML_OPTION_CASE_FOLDING');
$parser->set_element_handler('myOpenHandler','myCloseHandler');
$parser->set_data_handler('myDataHandler');
$parser->parser($xml);
get_current_position [line 664]
int get_current_position(
)
|
|
Returns the current string position of the "cursor" inside the XML document
Intended for use from within a user defined handler called via the $parser reference e.g.
function myDataHandler(& $parser,$data) {
echo( 'Current position: '.$parser->get_current_position() );
}
get_length [line 673]
Returns the string length of the XML document being parsed
parse [line 683]
void parse(
string
$data)
|
|
Start parsing some XML
Parameters:
set_data_handler [line 568]
void set_data_handler(
string
$data_method)
|
|
Sets the data handler method which deals with the contents of XML
elements.
The handler method must accept two arguments, the first being an instance of XML_HTMLSax3 and the second being the contents of an XML element e.g.
function myDataHander(& $parser,$data){}
Parameters:
set_element_handler [line 591]
void set_element_handler(
string
$opening_method, string
$closing_method)
|
|
Sets the open and close tag handlers
The open handler method must accept three arguments; the parser, the tag name and an array of attributes e.g.
function myOpenHander(& $parser,$tagname,$attrs=array()){}
The close handler method must accept two arguments; the parser and the tag name e.g.
function myCloseHander(& $parser,$tagname){}
Parameters:
set_escape_handler [line 628]
void set_escape_handler(
string
$escape_method)
|
|
Sets the XML escape handler method e.g. for comments and doctype
declarations
The handler method must accept two arguments; the parser and the contents of the escaped section
function myEscapeHander(& $parser, $data){}
Parameters:
set_jasp_handler [line 645]
void set_jasp_handler(
string
$jasp_method)
|
|
Sets the JSP/ASP markup handler
The handler method must accept two arguments; the parser and body of the JASP tag
function myJaspHander(& $parser, $data){}
Parameters:
set_object [line 506]
mixed set_object(
object handler
&$object)
|
|
Sets the user defined handler object. Returns a PEAR Error if supplied argument is not an object.
Parameters:
set_option [line 544]
boolean set_option(
string
$name, [int
$value = 1])
|
|
Sets a parser option. By default all options are switched off.
Returns a PEAR Error if option is invalid
Available options:
- XML_OPTION_TRIM_DATA_NODES: trim whitespace off the beginning
and end of data passed to the data handler
- XML_OPTION_LINEFEED_BREAK: linefeeds result in additional data
handler calls
- XML_OPTION_TAB_BREAK: tabs result in additional data handler
calls
- XML_OPTION_ENTITIES_UNPARSED: XML entities are returned as
seperate data handler calls in unparsed form
- XML_OPTION_ENTITIES_PARSED: (PHP 4.3.0+ only) XML entities are
returned as seperate data handler calls and are parsed with
PHP's html_entity_decode() function
- XML_OPTION_STRIP_ESCAPES: strips out the -- -- comment markers
or CDATA markup inside an XML escape, if found.
To get HTMLSax to behave in the same way as the native PHP SAX parser, using it's default state, you need to switch on XML_OPTION_LINEFEED_BREAK, XML_OPTION_ENTITIES_PARSED and XML_OPTION_CASE_FOLDING
Parameters:
set_pi_handler [line 610]
void set_pi_handler(
string
$pi_method)
|
|
Sets the processing instruction handler method e.g. for PHP open
and close tags
The handler method must accept three arguments; the parser, the PI target and data inside the PI
function myPIHander(& $parser,$target, $data){}
Parameters: