Why doesn't SimpleXMLElement?

Hello, there is a page that I've spars with vk
$curl = curl_init();
curl_setopt_array(
$curl,
array(
 CURLOPT_URL => 'https://vk.com/foaf.php?id=' . $user_id,
 CURLOPT_RETURNTRANSFER => true,
 CURLOPT_HEADER => false
)
 );

Transmitting data from Kurla to a variable and am checking
if (!($user_info = curl_exec($curl)))
 throw new Exception('failed to get user info!');
 elseif (!strpos($user_info, '<ya:firstname>'))
 throw new Exception('No user info!');</ya:firstname>

In the variable $user_info kept foaf code of this type
<?xml version="1.0" encoding="WINDOWS-1251"?>
<rdf:rdf xml:lang="EN" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:ya="http://blogs.yandex.ru/schema/foaf/" xmlns:img="http://blogs.yandex.ru/schema/foaf/" xmlns:dc="http://purl.org/dc/elements/1.1/">
<foaf:person>
<ya:publicaccess>allowed</ya:publicaccess>
<ya:profilestate>active</ya:profilestate>
 <ya:ya uri:primary="yes" rdf:resource="http://vk.com/id">
 <ya:uri rdf:resource="http://vk.com/">
<ya:firstname>Name</ya:firstname>
<ya:secondname>last Name</ya:secondname>
<foaf:name>Firstnamelastname</foaf:name>
 <foaf:weblog dc:title rdf:resource="http://vk.com/userid">
 <ya:created dc:date="2015-09-24T12:23:51+03:00">
 <ya:lastloggedin dc:date="2018-07-21T20:56:21+03:00">
 <ya:modified dc:date="2017-11-09T14:00:17+03:00">
<ya:subscriberscount>81</ya:subscriberscount>
<foaf:img>
 <foaf:image ya:primary="yes" img width="200" img:height="200" rdf:about="https://pp.userapi.com/c824203/v824203389/1535e8/F5vrkAA.jpg?ava=1">
 <foaf:thumbnail img:width="100" img:height="100" rdf:resource="https://pp.userapi.com/c824203/v824203389/1535e9/H2SCCwtu.jpg?ava=1">
 <foaf:thumbnail img:width="50" img:height="50" rdf:resource="https://pp.userapi.com/c824203/v824203389/1535ea/2_IRnPPir.jpg?ava=1">
</foaf:thumbnail></foaf:thumbnail></foaf:image>
</foaf:img>
</ya:modified></ya:lastloggedin></ya:created></foaf:weblog></ya:uri></ya:uri></foaf:person>
</rdf:rdf>

I need to place foaf:name. Trying to do it using SimpleXMLElement.
$xml = new SimpleXMLElement($user_info),
file_put_contents($file, $xml->xpath('//<foaf:name>'), FILE_APPEND)</foaf:name>

But when you run this code spilling errors
SimpleXMLElement::xpath(): Invalid expression in
SimpleXMLElement::xpath(): xmlXPathEval: evaluation failed in

What does he actually want?
June 3rd 19 at 19:11
1 answer
June 3rd 19 at 19:13
Solution
1. in xpath are not indicated by parentheses. accordingly, '//foaf:name'and not '//<foaf:name>'</foaf:name>
2. xpath will return an array, the entry in the file is meaningless.
Thank you, problem solved - josi commented on June 3rd 19 at 19:16

Find more questions by tags PHP