Replies: 2 comments
-
FluidXml has a well defined protocol on how it handles the array and your expressed case is quite uncommon/exceptional compared to the general pattern of an array of strings. In addition it is not possible to generalize your specific case (the key name that works for you will not work for someone else). What you should do is mapping your array to the XML structure you want: $list = [ 'abc 123', 'def 456' ];
$items = array_map(function ($it) { return [ 'idx' => $it ]; }, $list);
$xml->addChild($items); |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thanks for your response. It has been useful. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm trying to convert an array of strings to XML.
I get "Invalid Character Error" when calling
addChild()
:When removing the space, the exception is not thrown:
I'm expecting something like this:
I know I can achieve that with the following:
However, I was hoping FluidXml can do it automagically for me.
Is there a solution/workaround I can use?
Beta Was this translation helpful? Give feedback.
All reactions