diff --git a/typo3/sysext/core/Classes/Utility/GeneralUtility.php b/typo3/sysext/core/Classes/Utility/GeneralUtility.php index 64d357cd5ad4f22093900510e056e873b746976d..670eecfdbaa8a898ab8de96783c3353e13834112 100755 --- a/typo3/sysext/core/Classes/Utility/GeneralUtility.php +++ b/typo3/sysext/core/Classes/Utility/GeneralUtility.php @@ -1899,15 +1899,19 @@ class GeneralUtility { * * @param string $string XML data input * @param int $depth Number of element levels to resolve the XML into an array. Any further structure will be set as XML. + * @param array $parserOptions Options that will be passed to PHP's xml_parser_set_option() * @return mixed The array with the parsed structure unless the XML parser returns with an error in which case the error message string is returned. * @author bisqwit at iki dot fi dot not dot for dot ads dot invalid / http://dk.php.net/xml_parse_into_struct + kasperYYYY@typo3.com */ - static public function xml2tree($string, $depth = 999) { + static public function xml2tree($string, $depth = 999, $parserOptions = array()) { $parser = xml_parser_create(); $vals = array(); $index = array(); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 0); + foreach ($parserOptions as $option => $value) { + xml_parser_set_option($parser, $option, $value); + } xml_parse_into_struct($parser, $string, $vals, $index); if (xml_get_error_code($parser)) { return 'Line ' . xml_get_current_line_number($parser) . ': ' . xml_error_string(xml_get_error_code($parser)); diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-59384-XMLParserOptionsForXml2tree.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-59384-XMLParserOptionsForXml2tree.rst new file mode 100644 index 0000000000000000000000000000000000000000..5ca843cb70ad896b0d6bab9b0ae5afa959787f20 --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Feature-59384-XMLParserOptionsForXml2tree.rst @@ -0,0 +1,18 @@ +=================================================== +Feature: #59384 - XML parser options for xml2tree() +=================================================== + +Description +=========== + +GeneralUtility::xml_parser_set_option() gets an optional parameter, an array, that can hold options for the parser. Those will simply be passed through to the PHP-function xml_parser_set_option(). + +.. code-block:: php + + GeneralUtility::xml2tree($xmlData, 999, array(XML_OPTION_SKIP_WHITE => 1)); + + +Impact +====== + +It's just an optional parameter. If you don't specify it simply no additional initialisation of the XML-parser will be done.