I am trying to parse the starkoverflow.com/feeds/tag/{$tagName}
.
This is my code:
<?php
$xml = file_get_contents("http://stackoverflow.com/feeds/tag/php");
$simpleXml = simplexml_load_string($xml);
$attr = $simpleXml->entry->category->@attributes;
?>
When I execute the above code it gives me a error, Parse error: syntax error, unexpected '@', expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in D:\wamp\www\success\protoT.php on line 4
So, My question is how to get the array of the @attributes
?
Scrrenshot
You use the appropriately documented method: attributes()
Except that
$simpleXml->entry->category
is an array, so you need to specify which entry in the array you want to access:EDIT
Unless, as I have just learned, you only need to reference the first element