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.
/lib/ -> xmlize.php (source)

Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402]

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: 243 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.

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

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

Note: Used by xml element handler as callback.

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

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.

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

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

Note: Interface is kept equal to previous version.

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.
author: Kilian Singer

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.