@attribute elements in XML
- by danit
Here is my XML:
["link"]=>
array(2) {
[0]=>
object(SimpleXMLElement)#244 (1) {
["@attributes"]=>
array(3) {
["type"]=>
string(9) "text/html"
["href"]=>
string(48) "http://twitter.com/MoodleDan/statuses/1226112723"
["rel"]=>
string(9) "alternate"
}
}
[1]=>
object(SimpleXMLElement)#245 (1) {
["@attributes"]=>
array(3) {
["type"]=>
string(9) "image/png"
["href"]=>
string(59) "http://a3.twimg.com/profile_images/226895523/Dan_normal.png"
["rel"]=>
string(5) "image"
}
}
}
["author"]=>
object(SimpleXMLElement)#246 (2) {
["name"]=>
string(14) "Dan Humpherson"
["uri"]=>
string(16) "http://vl3.co.uk"
}
The above XML is part of a larger array, but how do i get the
href -> ["href"]=>
string(59) "http://a3.twimg.com/profile_images/226895523/Dan_normal.png"
Element to echo in PHP?
This is what I tried (Wrong I know)
foreach ($entry->link as $img) {
echo $img->href;
echo "<img src='". $img ."' />";
}