7
Could someone tell me how I do to get only the name value in the code below.
index page.
<?php
$curl = curl_init('http://localhost/server.php');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$resultado = curl_exec($curl);
curl_close($curl);
$xml = simplexml_load_string ($resultado);
echo $resultado;
echo $xml->nome;
?>
Server page:
$note=<<<xml
<note>
<nome>xiro</nome>
</note>
xml;
$xml = simplexml_load_string ($note);
var_dump($xml);
What problem are you having?
– stderr
I want to call the name (xiro) on the index page, but it doesn’t come. like this example https://www.youtube.com/watch?v=ipNK8Nigm08
– Xiro Nakamura
Unfortunately not. I would like to keep the initial structure with the Object(Simplexmlelement) and the public. Take a look at the video I posted above.
– Xiro Nakamura
If you explain better what you want to do, maybe there’s another way to do it.
– stderr
Thanks for your help friend, I followed your example and made some adaptations. I believe that in the video the pagseguro people use a mask to format XML.
– Xiro Nakamura
Great. If you want to post an answer explaining how you solved the problem it would be good, don’t forget to accept your answer as accepted. This could help other people with problems similar to yours.
– stderr
Dude, for the files you’ve been through, do this test take these two lines $xml = simplexml_load_string ($note); var_dump($xml); and put echo $note from the server file and tell me the result.
– Rodrigo Jarouche