Hallo,
ich hab ein Problem mit SimpleXML und ich komm auf keinen grünen Zweig, ich wirklich so gut wie alles durchprobiert.
Der XML Code:
Mein PHP Code:
aber ich kann in den Array nicht das letzte Attribut/Element des SimpleXML Objects speichern.
Es wird immer als SimpleXMLElement Object in den Array gespeichert.
So stehts im Array:
Ich will aber in dem Link-Array nur die URLs und als Index fortlaufende zahlen haben.
So:
Ich bekomme es einfach nicht hin.
Hoffe hier kann mir jemand weiterhelfen und erklären, an was ich nicht denke oder übersehe.
Besten Dank für Hilfe!
Gruß
ich hab ein Problem mit SimpleXML und ich komm auf keinen grünen Zweig, ich wirklich so gut wie alles durchprobiert.
Der XML Code:
Code:
<?xml version="1.0" encoding="UTF-8"?> <response> <name>Test</name> <methode>testing</methode> <antwort> <link url="http://example.com/"/> <link url="http://test.de/" desc="Testen" alsText="yah" /> <link url="http://php.de/"/> </antwort> <time used="12"/> </response>
Mein PHP Code:
PHP-Code:
$XMLContent = '...xml von oben...';
$XMLObject = simplexml_load_string($XMLContent);
$i=0;
foreach($XMLObject->antwort->link AS $b){
$links[] = $XMLObject->antwort->link[$i]->attributes();
$i++;
}
echo "<pre>Links ".print_r($links,true)."</pre>";
Es wird immer als SimpleXMLElement Object in den Array gespeichert.
So stehts im Array:
Code:
Links Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[url] => http://example.com/
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[url] => http://test.de/
[desc] => Testen
[alsText] => yah
)
)
[2] => SimpleXMLElement Object
(
[@attributes] => Array
(
[url] => http://php.de/
)
)
)
So:
Code:
Links Array( [0]=>http://example.com [1]=>http://test.de [2]=>http://php.de ... )
Hoffe hier kann mir jemand weiterhelfen und erklären, an was ich nicht denke oder übersehe.
Besten Dank für Hilfe!
Gruß


Kommentar