@attribute elements in XML
Posted
by danit
on Stack Overflow
See other posts from Stack Overflow
or by danit
Published on 2010-04-01T12:50:08Z
Indexed on
2010/04/01
12:53 UTC
Read the original article
Hit count: 296
php
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 ."' />";
}
© Stack Overflow or respective owner