Laravel how to output db records as XML?



I cant deal with such simple (I think) thing like output records from database as XML. I have eloquent model named Customer and I want to send to output all customers from db so I've tried to install response macro ( http://www.laravel-tricks.com/tricks/responsexml-macro ) and I call it like this:



public function showCustomers()
{
$customers = Customer::all()->toArray();
return Response::xml($customers);
}


but then I got error "SimpleXMLElement::addChild(): unterminated entity reference M" . I tried also other solution which used SimpleXMLELement also so the result was the same.


No comments:

Post a Comment