MarcosKlender
1 week ago

From Database (Text) to XML

Posted 1 week 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

<?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="http://www.sitemaps.org/schemas/sitemap/0.9">
    {{ $data }}
</urlset>

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.