Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 401 and 402]

(no description)

File Size: 1092 lines (49 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

XMLParser:: (17 methods):
  __construct()
  parse()
  xmlrpc_se()
  xmlrpc_ee()
  xmlrpc_ee_fast()
  xmlrpc_ee_epi()
  xmlrpc_cd()
  xmlrpc_dh()
  guessEncoding()
  hasEncoding()
  handleParsingError()
  truncateValueForLog()
  xmlrpc_se_any()
  __get()
  __set()
  __isset()
  __unset()


Class: XMLParser  - X-Ref

Deals with parsing the XML.

__construct(array $options = array()   X-Ref

param: array $options integer keys: options passed to the inner xml parser

parse($data, $returnType = self::RETURN_XMLRPCVALS, $accept = 3, $options = array()   X-Ref
Parses an xml-rpc xml string. Results of the parsing are found in $this->['_xh'].
Logs to the error log any issues which do not cause the parsing to fail.

param: string $data
param: string $returnType self::RETURN_XMLRPCVALS, self::RETURN_PHP, self::RETURN_EPIVALS
param: int $accept a bit-combination of self::ACCEPT_REQUEST, self::ACCEPT_RESPONSE, self::ACCEPT_VALUE
param: array $options integer-key options are passed to the xml parser, string-key options are used independently.
return: array see the definition of $this->_xh for the meaning of the results

xmlrpc_se($parser, $name, $attrs, $acceptSingleVals = false)   X-Ref
xml parser handler function for opening element tags.

param: resource $parser
param: string $name
param: $attrs
param: bool $acceptSingleVals DEPRECATED use the $accept parameter instead
return: void

xmlrpc_ee($parser, $name, $rebuildXmlrpcvals = 1)   X-Ref
xml parser handler function for close element tags.

param: resource $parser
param: string $name
param: int $rebuildXmlrpcvals >1 for rebuilding xmlrpcvals, 0 for rebuilding php values, -1 for xmlrpc-extension compatibility
return: void

xmlrpc_ee_fast($parser, $name)   X-Ref
Used in decoding xml-rpc requests/responses without rebuilding xml-rpc Values.

param: resource $parser
param: string $name
return: void

xmlrpc_ee_epi($parser, $name)   X-Ref
Used in decoding xml-rpc requests/responses while building xmlrpc-extension Values (plain php for all but base64 and datetime).

param: resource $parser
param: string $name
return: void

xmlrpc_cd($parser, $data)   X-Ref
xml parser handler function for character data.

param: resource $parser
param: string $data
return: void

xmlrpc_dh($parser, $data)   X-Ref
xml parser handler function for 'other stuff', i.e. not char data or element start/end tag.
In fact, it only gets called on unknown entities...

param: $parser
param: string data
return: void

guessEncoding($httpHeader = '', $xmlChunk = '', $encodingPrefs = null)   X-Ref
xml charset encoding guessing helper function.
Tries to determine the charset encoding of an XML chunk received over HTTP.
NB: according to the spec (RFC 3023), if text/xml content-type is received over HTTP without a content-type,
we SHOULD assume it is strictly US-ASCII. But we try to be more tolerant of non-conforming (legacy?) clients/servers,
which will be most probably using UTF-8 anyway...
In order of importance checks:
1. http headers
2. BOM
3. XML declaration
4. guesses using mb_detect_encoding()

param: string $httpHeader the http Content-type header
param: string $xmlChunk xml content buffer
param: string $encodingPrefs comma separated list of character encodings to be used as default (when mb extension is enabled).
return: string the encoding determined. Null if it can't be determined and mbstring is enabled,

hasEncoding($xmlChunk)   X-Ref
Helper function: checks if an xml chunk has a charset declaration (BOM or in the xml declaration).

param: string $xmlChunk
return: bool

handleParsingError($message, $method = '')   X-Ref

param: string $message
param: string $method method/file/line info
return: bool false if the caller has to stop parsing

truncateValueForLog($data)   X-Ref
Truncates unsafe data

param: string $data
return: string

xmlrpc_se_any($parser, $name, $attrs)   X-Ref
xml parser handler function for opening element tags.
Used in decoding xml chunks that might represent single xml-rpc values as well as requests, responses.

param: resource $parser
param: $name
param: $attrs
return: void

__get($name)   X-Ref
No description

__set($name, $value)   X-Ref
No description

__isset($name)   X-Ref
No description

__unset($name)   X-Ref
No description