class XmlUtils
XMLUtils is a bunch of utility methods to XML operations.
This class contains static methods only and is not meant to be instantiated.
static DOMDocument | parse(string $content, string|callable|null $schemaOrCallable = null) Parses an XML string. | |
static DOMDocument | loadFile(string $file, string|callable|null $schemaOrCallable = null) Loads an XML file. | |
static array | convertDomElementToArray(DOMElement $element, bool $checkPrefix = true) Converts a \DOMElement object to a PHP array. | |
static mixed | phpize(mixed $value) Converts an xml value to a PHP type. | |
static | getXmlErrors($internalErrors) |
Parses an XML string.
string | $content | An XML string |
string|callable|null | $schemaOrCallable | An XSD schema file path, a callable, or null to disable validation |
DOMDocument |
XmlParsingException | When parsing of XML file returns error |
InvalidXmlException | When parsing of XML with schema or callable produces any errors unrelated to the XML parsing itself |
RuntimeException | When DOM extension is missing |
Loads an XML file.
string | $file | An XML file path |
string|callable|null | $schemaOrCallable | An XSD schema file path, a callable, or null to disable validation |
DOMDocument |
InvalidArgumentException | When loading of XML file returns error |
XmlParsingException | When XML parsing returns any errors |
RuntimeException | When DOM extension is missing |
Converts a \DOMElement object to a PHP array.
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 (
The attributes are converted to keys ()
The nested-tags are converted to keys (
DOMElement | $element | A \DOMElement instance |
bool | $checkPrefix | Check prefix in an element or an attribute name |
array | A PHP array |
Converts an xml value to a PHP type.
mixed | $value |
mixed |
$internalErrors |
© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/Config/Util/XmlUtils.html