Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
XMLParser Class Reference

Public Member Functions

 addError ($error)
 
createParser ()
 
 destroy ()
 
 destroyParser ($parser)
 
 getErrors ()
 
 getStatus ()
 
parse ($file, $dataCallback=null)
 
parseStruct ($file, $tagsToMatch=array())
 
parseTextStruct (&$text, $tagsToMatch=array())
 
 setHandler (&$handler)
 
 XMLParser ()
 

Public Attributes

 $errors
 
 $handler
 
 $magicQuotes
 

Detailed Description

Generic class for parsing an XML document into a data structure.

Definition at line 28 of file XMLParser.inc.php.

Member Function Documentation

XMLParser::addError (   $error)

Add an error to the current error list

Parameters
$errorstring

Definition at line 193 of file XMLParser.inc.php.

& XMLParser::createParser ( )

Initialize a new XML parser.

Returns
resource

Definition at line 279 of file XMLParser.inc.php.

XMLParser::destroy ( )

Perform required clean up for this object.

Definition at line 297 of file XMLParser.inc.php.

XMLParser::destroyParser (   $parser)

Destroy XML parser.

Parameters
$parserresource

Definition at line 290 of file XMLParser.inc.php.

XMLParser::getErrors ( )

Get the current list of errors

Definition at line 200 of file XMLParser.inc.php.

XMLParser::getStatus ( )

Determine whether or not the parser encountered an error (false) or completed successfully (true)

Returns
boolean

Definition at line 209 of file XMLParser.inc.php.

& XMLParser::parse (   $file,
  $dataCallback = null 
)

Parse an XML file using the specified handler. If no handler has been specified, XMLParserDOMHandler is used by default, returning a tree structure representing the document.

Parameters
$filestring full path to the XML file
$dataCallbackmixed Optional callback for data handling: function dataCallback($operation, $wrapper, $data = null)
Returns
object actual return type depends on the handler

Definition at line 106 of file XMLParser.inc.php.

& XMLParser::parseStruct (   $file,
  $tagsToMatch = array() 
)

Parse an XML file using xml_parse_into_struct and return data in an array. This is best suited for XML documents with fairly simple structure.

Parameters
$filestring full path to the XML file
$tagsToMatcharray optional, if set tags not in the array will be skipped
Returns
array a struct of the form ($TAG => array('attributes' => array( ... ), 'value' => $VALUE), ... )

Definition at line 263 of file XMLParser.inc.php.

& XMLParser::parseTextStruct ( $text,
  $tagsToMatch = array() 
)

Parse XML data using xml_parse_into_struct and return data in an array. This is best suited for XML documents with fairly simple structure.

Parameters
$textstring XML data
$tagsToMatcharray optional, if set tags not in the array will be skipped
Returns
array a struct of the form ($TAG => array('attributes' => array( ... ), 'value' => $VALUE), ... )

Definition at line 228 of file XMLParser.inc.php.

XMLParser::setHandler ( $handler)

Set the handler to use for parse(...).

Parameters
$handlerXMLParserHandler

Definition at line 217 of file XMLParser.inc.php.

Referenced by XMLParser().

XMLParser::XMLParser ( )

Constructor. Initialize parser and set parser options.

Definition at line 52 of file XMLParser.inc.php.

References $handler, and setHandler().

Member Data Documentation

array XMLParser::$errors

List of error strings

Definition at line 46 of file XMLParser.inc.php.

object XMLParser::$handler

instance of XMLParserHandler

Definition at line 40 of file XMLParser.inc.php.

Referenced by XMLParser().

int XMLParser::$magicQuotes

original magic_quotes_runtime setting

Definition at line 34 of file XMLParser.inc.php.


The documentation for this class was generated from the following file: