Support the ongoing development of Laravel.io →
Views Blade Architecture

I have created a storelocator.php in my view with the following code :

<?php $dom = new DOMDocument("1.0"); $node = $dom->createElement("markers"); $parnode = $dom->appendChild($node); header("Content-type: text/xml"); foreach ($results as $value){ // ADD TO XML DOCUMENT NODE $node = $dom->createElement("marker"); $newnode = $parnode->appendChild($node); $newnode->setAttribute("name",$value->dealer_name); $newnode->setAttribute("address", $value->address); $newnode->setAttribute("lat", $value->lat); $newnode->setAttribute("lng", $value->lng); $newnode->setAttribute("type", $value->outlet_type); } echo $dom->saveXML(); ?>

My Route is:

Route::get('/storelocator','SearchController@showReviews');

my ShowReviews Function

public function showReviews()
    {

     //$dealer_address = dealer_addresss::lists('dealer_name','address','lat','lng','outlet_type');
     //return view('/reviews',compact('dealer_address')); 
    $results = DB::table('dealer_address')
                ->get();
   
    //return view('/reviewresults',compact('results'));

     return view('/storelocator',compact('results')); 
    }

All I get is a blank page: When I click on source I am able to the xml content with the data but on hover it says Attempt to use an XML processing instruction in HTML.

What am I doing wrong here ? Any guide would be immensely appreciated.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

exelrate exelrate Joined 13 Oct 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.