Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.
/lib/ -> xmlize.php (source)

Differences Between: [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]

Code for parsing xml files. Handles functionality for:

Copyright: Kilian Singer
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 245 lines (9 kb)
Included or required: 1 time
Referenced: 1 time
Includes or requires: 0 files

Defines 2 classes

xml_format_exception:: (1 method):
  __construct()

core_xml_parser:: (5 methods):
  startelement()
  endelement()
  characterdata()
  parse()
  xmlize()


Class: xml_format_exception  - X-Ref

__construct($errorstring, $line, $char, $link = '')   X-Ref
Constructor function

param: string $errorstring Errorstring
param: int $line Linenumber
param: char $char Errorcharacter
param: string $link Link

Class: core_xml_parser  - X-Ref

Class for parsing xml files.

Handles functionality for:

Import of xml files in questionbank and course import.
Can handle xml files larger than 10MB through chunking the input file.
Uses a similar interface to the original version xmlize() by Hans Anderson.

startelement($parser, $name, $attrs)   X-Ref
Is called when tags are opened.

Note: Used by xml element handler as callback.

author: Kilian Singer
param: resource $parser The XML parser resource.
param: string $name The XML source to parse.
param: array $attrs Stores attributes of XML tag.

endelement($parser, $name)   X-Ref
Is called when tags are closed.

Note: Used by xml element handler as callback.

author: Kilian Singer
param: resource $parser The XML parser resource.
param: string $name The XML source to parse.

characterdata($parser, $data)   X-Ref
Is called for text between the start and the end of tags.

Note: Used by xml element handler as callback.

author: Kilian Singer
param: resource $parser The XML parser resource.
param: string $data The XML source to parse.

parse($data, $whitespace = 1, $encoding = 'UTF-8', $reporterrors = false)   X-Ref
Parses XML string.

Note: Interface is kept equal to previous version.

author: Kilian Singer
param: string $data the XML source to parse.
param: int $whitespace If set to 1 allows the parser to skip "space" characters in xml document. Default is 1
param: string $encoding Specify an OUTPUT encoding. If not specified, it defaults to UTF-8.
param: bool $reporterrors if set to true, then a {@link xml_format_exception}
return: array representation of the parsed XML.

xmlize($data, $whitespace = 1, $encoding = 'UTF-8', $reporterrors = false)   X-Ref
XML parsing function calles into class.

Note: Used by xml element handler as callback.

param: string $data the XML source to parse.
param: int $whitespace If set to 1 allows the parser to skip "space" characters in xml document. Default is 1
param: string $encoding Specify an OUTPUT encoding. If not specified, it defaults to UTF-8.
param: bool $reporterrors if set to true, then a {@link xml_format_exception}
return: array representation of the parsed XML.