This is sort of confusing to explain, so thank you ahead of time for bearing with me.
I am using Kohana PHP framework to develop an application. I have a model function that accepts parameters for a search, and should return an XML styled page. I need this to be read by the controller with SimpleXML. Any ideas how to do this?
$o = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$o .= "<feed>\n";
$o .= "\t<search_phrase>$q</search_phrase>\n";
if(isset($entries)){
uasort($entries, 'compare_weight');
/**
* Build the xml data
*/
foreach($modules as $module){
$o .= "\t<search_location>$module</search_location>\n";
}
foreach($entries as $k=>$entry){
$o .= "\n\t<entry>\n";
$o .= "\t\t<title>$entry[title]</title>\n";
$o .= "\t\t<url>$entry[url]</url>\n";
$o .= "\t\t<weight>$entry[weight]</weight>\n";
$o .= "\t\t<module>$entry[module]</module>\n";
if($entry['owners']){
foreach($entry['owners'] as $owner){
$o .= "\t\t<owners>\n";
$o .= "\t\t\t<owner_id>$owner[owner_id]</owner_id>\n";
$o .= "\t\t\t<owner_name>$owner[owner_name]</owner_name>\n";
$o .= "\t\t\t<profile_link>$owner[profile_link]</profile_link>\n";
$o .= "\t\t</owners>\n";
}
}
$o .= "\t</entry>\n";
}
}else{
$o .= "\t<noresult>true</noresult>\n";
}
$o .= "</feed>\n";
return $o;
The controller functions like this... It's the closest I'm able to come to wrapping my head how to do this.
$return= $this->search->search($_GET);
$xml = new SimpleXMLElement($return);
die($xml);
It returns a blank document with 44 blank lines. Any direction would be helpful.