Open Journal Systems  2.4.3
 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 ()
 

Detailed Description

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

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

Member Function Documentation

XMLParser::addError (   $error)

Add an error to the current error list

Parameters
$errorstring

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

Referenced by parse().

& XMLParser::createParser ( )

Initialize a new XML parser.

Returns
resource

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

Referenced by parse(), and parseTextStruct().

XMLParser::destroy ( )

Perform required clean up for this object.

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

XMLParser::destroyParser ( $parser)

Destroy XML parser.

Parameters
$parserresource

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

Referenced by parse(), and parseTextStruct().

XMLParser::getErrors ( )

Get the current list of errors

Definition at line 192 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 201 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 97 of file XMLParser.inc.php.

References addError(), createParser(), destroyParser(), String\getHTMLEntities(), Config\getVar(), setHandler(), String\strlen(), String\substr(), String\utf8_bad_find(), String\utf8_bad_strip(), String\utf8_compliant(), String\utf8_normalize(), String\utf8_strip_ascii_ctrl(), and FileWrapper\wrapper().

& 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 255 of file XMLParser.inc.php.

References parseTextStruct(), and FileWrapper\wrapper().

& 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 220 of file XMLParser.inc.php.

References createParser(), and destroyParser().

Referenced by parseStruct().

XMLParser::setHandler ( $handler)

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

Parameters
$handlerXMLParserHandler

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

Referenced by parse().

XMLParser::XMLParser ( )

Constructor. Initialize parser and set parser options.

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


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