How do I extract attributes from this xml object
<designs>
<tags>
.
.
.
</tags>
<templates>
<template id="photographysite" image="http://example.com/en/previews/photographysitePreview434x326.jpg" name="Shutter" thumb="http://example.com/en/previews/photographysitePreview182x137.jpg">
<tag>all</tag>
<tag>featured</tag>
<tag>personal</tag>
<tag>portfolio</tag>
<tag>photography</tag>
<tag>business</tag>
</template>
</templates>
</designs>
If I consider each object as $template
, then this syntax wont work.
foreach ($xmldoc->templates as $template) {
$attributes = $template->attributes();
echo '<img src="' . $attributes['thumb'] . '" />';
}