Iki adımda gitmek zorunda:
- Get the XML string from the remote server
- and, then, parse that XML to extract the data
Bu iki adımlar sunucu yapılandırma bunu izin veriyorsa, simplexml_load_file
a> kullanarak, biri olarak birleştirilmiş olabilir unutmayın.
Once you have that XML in a PHP variable, using SimpleXML, it's quite easy to get the value you want. For instance :
$string = '<?xml version="1.0" ?><Tracker>12345</Tracker>';
$xml = simplexml_load_string($string);
echo (string)$xml;
Alırsınız
12345
And getting the content of that XML from the remote URL can be as simple as :
$string = file_get_contents('http://your-remote-url');
Bunu eğer Ve, aynı zamanda SimpleXML ile doğrudan o uzak URL kullanabilirsiniz:
$xml = simplexml_load_file('http://your-remote-url');
echo (string)$xml;
allow_url_fopen
a> sunucunun yapılandırma etkinse Ama bu sadece çalışır.
If allow_url_fopen
is disabled on your server, you can get the XML from the remote server using curl ; something like this should do the trick, for instance :
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://your-remote-url");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$string = curl_exec($ch);
curl_close($ch);
Benim ilk örnekte olduğu gibi, sonra, yine, simplexml_load_string
kullanabilirsiniz.
(If using curl, take a look at the documentation of curl_setopt
: there are several options that might interest your -- for instance, to specify timeouts)