I feel like both existing answers tell you half of what you need to know.
Firstly, your XPath is subtly wrong: b[@id] means "any b element which has an attribute id". You want instead b/@id, meaning "any id attribute which is a child of a b element".
Secondly, the SimpleXML xpath method returns an array of SimpleXMLElement objects representing the elements or attributes matched. To get just the text contents of those attributes, you need to cast each one to string, using (string)$foo.
So:
$xmlfile = simplexml_load_file("test.xml");
$test = $xmlfile->xpath("/a//b/@id");
$list = [];
foreach ( $test as $attr ) {
$list[] = (string)$attr;
}
[Live Demo]