[TYPO3-dev] How to use xml2array()
Jigal van Hemert
jigal.van.hemert at typo3.org
Mon Dec 1 11:29:59 CET 2014
Hi,
On 01/12/2014 09:41, bernd wilke wrote:
> I'm trying to use \TYPO3\CMS\Core\Utility\GeneralUtility::xml2array() to
> analyse a fluid-template.
>
> first problem were the namespace declarations in the beginning of the
> template. But removing them with preg_replace() solved this.
>
>
> Now I get the Error
> | Line 2: Invalid document end
>
> can't xml2array() handle tags over multiple lines?
xml2array() was designed for parsing flexform values. I have indeed seen
problems with tags spread over multiple lines if they only contain a value:
<tag>
value
</tag>
went wrong and
<tag>value</tag>
was no problem.
> BTW: I can't figure about the second paramter of xml2array():
> what is it for?
> how can I use it?
That parameter can be used to pass a namespace to the function. The xml
parser that is used apparently returns the tag names including the
namespace prefix. If a tag is found that starts with the namespace it's
removed before making an entry in the array.
Perhaps a different XML parser is more useful in this case...
--
Jigal van Hemert
TYPO3 CMS Active Contributor
TYPO3 .... inspiring people to share!
Get involved: typo3.org
More information about the TYPO3-dev
mailing list