Moin Moin,
mb_... hab ich auch schon alles probiert - langsam zweifel ich echt an mir.
Ich hab rausgefunden, dass die Funktion "get_object_vars" anscheinend was damit zu tun hat. Wenn ich hier das encoding checke bekomme ich "ASCII" dummerweise läßt sich das nicht auf UTF-8 konvertieren.
Ich poste hier mal die Funktion die mir aus dem XML ein Array macht:
PHP-Code:
function objectsIntoArray($arrObjData, $arrSkipIndices = array())
{
$arrData = array();
// if input is object, convert into array
if (is_object($arrObjData)) {
$arrObjData = get_object_vars($arrObjData);
}
if (is_array($arrObjData)) {
foreach ($arrObjData as $index => $value) {
if (is_object($value) || is_array($value)) {
$value = objectsIntoArray($value, $arrSkipIndices); // recursive call
}
if (in_array($index, $arrSkipIndices)) {
continue;
}
$arrData[$index] = $value;
}
}
return $arrData;
}
Die XML wird ganz normal eingelesen:
PHP-Code:
$xmlStr = file_get_contents($datafile);
$xmlObj = simplexml_load_string($xmlStr, null, LIBXML_NOCDATA);
$arrXml = objectsIntoArray($xmlObj);
Und dann läuft eine Schleife darüber und ließt die Inhalte aus:
PHP-Code:
for($x = 0; $x < count($arrXml['product']); $x++) {
if($arrXml['product'][$x]['@attributes']['hot'] > 0 OR
($arrXml['product'][$x]['@attributes']['hot'] < 11 AND
$arrXml['product'][$x]['@attributes']['hot'] != 0)) {
// $angebotArr[] = $arrXml['product'][$x];
if($x % 2 == 0) {
$ausgabe .= '<tr>';
$ausgabe .= '<td valign="top">';
} else {
$ausgabe .= '<td valign="top">';
}
$ausgabe .= '<a href="'.$arrXml['product'][$x]['deeplink']['@attributes']['path'].'" target="_top">';
$ausgabe .= $arrXml['product'][$x]['title'].'</a><br>';
$ausgabe .= '<a href="'.$arrXml['product'][$x]['deeplink']['@attributes']['path'].'" target="_top">
<img src="'.$arrXml['product'][$x]['image']['@attributes']['path'].'" border="0">
</a><br>'.$arrXml['product'][$x]['description'].'<br><hr>';
if($x % 2 == 0) {
$ausgabe .= '</td>';
} else {
$ausgabe .= '</td>';
$ausgabe .= '</tr>';
}
}
}
$ausgabe .= '</table>';
echo $ausgabe;