XmlUtils
in package
XMLUtils is a bunch of utility methods to XML operations.
This class contains static methods only and is not meant to be instantiated.
Tags
Table of Contents
Methods
- convertDomElementToArray() : mixed
- Converts a \DOMElement object to a PHP array.
- loadFile() : DOMDocument
- Loads an XML file.
- parse() : DOMDocument
- Parses an XML string.
- phpize() : mixed
- Converts an xml value to a PHP type.
- getXmlErrors() : mixed
- __construct() : mixed
- This class should not be instantiated.
- isOctal() : bool
Methods
convertDomElementToArray()
Converts a \DOMElement object to a PHP array.
public
static convertDomElementToArray(DOMElement $element[, bool $checkPrefix = true ]) : mixed
The following rules applies during the conversion:
-
Each tag is converted to a key value or an array if there is more than one "value"
-
The content of a tag is set under a "value" key (
bar ) if the tag also has some nested tags -
The attributes are converted to keys (
) -
The nested-tags are converted to keys (
)bar
Parameters
- $element : DOMElement
-
A \DOMElement instance
- $checkPrefix : bool = true
-
Check prefix in an element or an attribute name
loadFile()
Loads an XML file.
public
static loadFile(string $file[, string|callable|null $schemaOrCallable = null ]) : DOMDocument
Parameters
- $file : string
-
An XML file path
- $schemaOrCallable : string|callable|null = null
-
An XSD schema file path, a callable, or null to disable validation
Tags
Return values
DOMDocumentparse()
Parses an XML string.
public
static parse(string $content[, string|callable|null $schemaOrCallable = null ]) : DOMDocument
Parameters
- $content : string
-
An XML string
- $schemaOrCallable : string|callable|null = null
-
An XSD schema file path, a callable, or null to disable validation
Tags
Return values
DOMDocumentphpize()
Converts an xml value to a PHP type.
public
static phpize(string|Stringable $value) : mixed
Parameters
- $value : string|Stringable
getXmlErrors()
protected
static getXmlErrors(bool $internalErrors) : mixed
Parameters
- $internalErrors : bool
__construct()
This class should not be instantiated.
private
__construct() : mixed
isOctal()
private
static isOctal(string $str) : bool
Parameters
- $str : string