I am Parsing XML currently using:
$data = simplexml_load_string($xmlFile);
foreach($data->item as $key => $current){
echo($current);
}
However I'm wondering, if a hit an element that looks like this:
<thumbnail url="http://foo.bar" height="225" width="300"/>
How do i pull the inner parts of this? (height, url, width)
Thanks!
foreach($data->item->thumbnail as $thumbnail) {
$url = $thumbnail['url'];
$height = $thumbnail['height'];
$width = $thumbnail['width'];
}
In case you don't know how many attributes there will be...
foreach ($data->item->thumbnail->attributes() as $key => $value) {
$attr[$key] = (string)$value;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.