How to loop without parent node ?
t-prod opened this issue · 4 comments
t-prod commented
Hi,
Thanks for your package. I would like to loop by adding in XML
<Line>
<Sku>XXX</Sku>
<Qty>1</Qty>
</Line>
With this it creates a parent node but I don't need to. How can I do to only do a simple loop without a parent node ?
->startLoop('Users', [], function (XMLArray $XMLArray) use ($users) {
foreach ($users as $user) {
$XMLArray->start('User')
->add('name', $user['name'])
->add('age', $user['age']);
}
})
->end()
p3king commented
You should be able to just use "loop" instead of "startLoop" if I understood you right, thats what I currently do:
->loop(function (XMLArray $XMLArray) use ($users) {
foreach ($users as $user) {
$XMLArray->start('User')
->add('name', $user['name'])
->add('age', $user['age']);
}
})
t-prod commented
That's perfect I did not see the loop function ;) Thanks again
AaronDDM commented
Will do, thanks guys!