I have the following XML:
<category-links>
<category-link id="2350">
<name locale="de">Wasserkocher</name>
</category-link>
</category-links>
I have turned it into an array with SimpleXML, and the result looks like this:
[category-links] => SimpleXMLElement Object
(
[category-link] => SimpleXMLElement Object
(
[@attributes] => Array
(
[id] => 2350
)
[name] => Wasserkocher
)
)
I want to output the following:
<tr>
<td>category-link > id</td>
<td><?= $p->{'category-links'}->{'category-link'}->{'@attributes'}->id ?></td>
</tr>
<tr>
<td>category-link > name</td>
<td><?= $p->{'category-links'}->{'category-link'}->name ?></td>
</tr>
Only name
gives the expected result (Wasserkocher), while nothing is shown for id
.
var_dump($p->{'category-links'}->{'category-link'}->{'@attributes'}->id)
gives NULL.
Replacing arrows by brackets in various ways doesn't change anything.
I guess, I could "solve" the problem with a string replace, removing the @ sign in the array.
Is there any way to output ID without making this rather clumsy measure?