Posts

Showing posts with the label xml

How to get XML response output in laravel?

How to get XML response output in laravel? or How to create XML response output in laravel? or Most of developers use header function to create xml file but this does not work header('Content-type: application/xml'); $output  = "<?xml version='1.0' encoding='UTF-8'?>"; here i will tell you that how can you show or save XML response output in laravel you have an array where you have data Here is an example that how can you create xml file response in laravel suppose you have an array which have twitter data //Preapre our output for xml data $output  = "<?xml version='1.0' encoding='UTF-8'?>"; $output .= "\n<twitterfeed>\n"; $j=0; foreach($twitterinfo as $row){ $j++; $output .= "<feed>\n"; $output .= "<id>" . $j . "</id>\n"; $output .= "<twitter_id>" . $row['twitter_id'] . "</twitter_id>\n"

EntityRef: expecting ';' error while creating the xml file?

This page contains the following errors: error on line 68 at column 18: EntityRef: expecting ';' Below is a rendering of the page up to the first error. Generally  this error occured when any value have & in the value between tag example:  <Name>PHP & C</Name> So & break the xml and due to this it shows the error just replace   & with  &amp   in your value field example:  $output .= "<Name>" . str_replace('&', '&amp;', $row['name']) . "</Name>"; I hope this will help you. If helped then dont forget to comment to inspire me :)