R
R
Roman2019-02-14 00:00:25
XML
Roman, 2019-02-14 00:00:25

How to convert Laravel collection (or array) to XML?

Hello!
When migrating to Laravel, the function of outputting a query from the database as an XML document "broke". Problems started with the format (it makes me some kind of terrible hybrid of JSON and XML))) and with the encoding (gives all sorts of \u043f\u043e\u043d\u0440\u0430 and

$xml_string = html_entity_decode($xml_string, ENT_NOQUOTES, 'UTF-8');

does not help (before Laravel, it helped)))
What should I do?
How to easily and simply display a query like:
$xml = $model->whereBetween('created_at', [$date_from, $date_to])->get();

as a valid XML document?
I'm already leaning towards the fact that it's easier to assemble it "by hand" in a cycle.
But if there are ready-made solutions, I will be glad to learn about them.
Thank you.
P.S. In general, if you reformulate the original question, it sounds like this:
- How can you turn a Laravel collection into a regular multidimensional associative array with string values?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yurik Bulkin, 2019-02-14
@procode

https://github.com/search?q=laravel+xml+response
Choose

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question