4 months ago

From Database (Text) to XML

Posted 4 months ago by MarcosKlender

Hi guys,

In my bdd I have a column (text) called "xml_documento" which store a XML in text format. I need to pass them on a view with all the XML structure. Then I want to change that view with CSS.

Here's my CustomerController.php


namespace WebServiceApp\Http\Controllers;

use Illuminate\Http\Request;
use WebServiceApp\Customer;
use PDF;

class CustomerController extends Controller
  public function export_pdf()
    $data = Customer::select('xml_documento')->get();

    return response()->view('test', compact('data'))->header('Content-Type', 'text/xml');


And here's my test.blade.php

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="">
    {{ $data }}

I don't have errors when I refresh the page but the content retrieved from database ($data) still remains as text. I need to transform that text to XML too. Please help! :(

Please sign in or create an account to participate in this conversation.