Hi,
I was wondering if anyone could help me out with generating xml output instead of the regular xhtml files using skins.
I wish to incorporate b2evolution blog on our gaming site www.zapak.com
and we are mostly using xslt & ajax for template creation.
So essentially what i require is to generate xml file output within the php code instead of xhtml output.
After having gone through the code of b2evolution blog I require the array output to be in xml.
Could someone help me out as to where exactly do i need to include the following code for dynamically outputting xml files from mysql blog db in b2evolution blog database.
function array_to_xml($array, $level=1) {
$xml = '';
foreach ($array as $key=>$value) {
$key = ereg_replace('\.','dot_',$key);
$key = strtolower($key);
if (is_object($value)) {$value=get_object_vars($value);}// convert object to array
if (is_array($value)) {
$multi_tags = false;
foreach($value as $key2=>$value2) {
$key2 = ereg_replace('\.','dot_',$key2);
if (is_object($value2)) {$value2=get_object_vars($value2);} // convert object to array
if (is_array($value2)) {
$xml .= str_repeat("\t",$level)."<$key>\n";
$xml .= array_to_xml($value2, $level+1);
$xml .= str_repeat("\t",$level)."</$key>\n";
$multi_tags = true;
} else {
if (trim($value2)!='') {
if (htmlspecialchars($value2)!=$value2) {
$xml .= str_repeat("\t",$level).
"<$key2><![CDATA[$value2]]>". // changed $key to $key2... didn't work otherwise.
"</$key2>\n";
} else {
$xml .= str_repeat("\t",$level).
"<$key2>$value2</$key2>\n"; // changed $key to $key2
}
}
$multi_tags = true;
}
}
if (!$multi_tags and count($value)>0) {
$xml .= str_repeat("\t",$level)."<$key>\n";
$xml .= array_to_xml($value, $level+1);
$xml .= str_repeat("\t",$level)."</$key>\n";
}
} else {
if (trim($value)!='') {
//echo "value=$value<br>";
if (htmlspecialchars($value)!=$value) {
$xml .= str_repeat("\t",$level)."<$key>".
"<![CDATA[$value]]></$key>\n";
} else {
$xml .= str_repeat("\t",$level).
"<$key>$value</$key>\n";
}
}
}
}
return $xml;
}
You should be able to amend one of the rss skins to suit your needs.
¥