I want to read three values of XML in PHP
$url = "Http://www.cailele.com/static/ssc/newlyopenlist.xml";
$doc = new DOMDocument ();
$doc->load ($url); Reading an XML file
$lst = $doc->getelementsbytagname (' Row ');
for ($i =0; $i <2; $i + +) {
$iframe = $lst->item ($i);
$t 1= $iframe->attributes->getnameditem (' expect ')->value;
$t 2= $iframe->attributes->getnameditem (' Opencode ')->value;
$t 3= $iframe->attributes->getnameditem (' opentime ')->value;
$t 1=substr ($t 1,-9);
Kjdata ($t 2,1, $t 1, $t 3);
I want to read the XML Expec,opencode,opentime three values, do not know why the reading is not, ask for answers
------Solution--------------------
$url = "Http://www.cailele.com/static/ssc/newlyopenlist.xml";
$doc = new DOMDocument ();
$doc->loadxml (Curl_get ($url));
$lst = $doc->getelementsbytagname (' Row ');
for ($i =0; $i <2; $i + +) {
$iframe = $lst->item ($i);
$t 1= $iframe->attributes->getnameditem (' expect ')->value;
$t 2= $iframe->attributes->getnameditem (' Opencode ')->value;
$t 3= $iframe->attributes->getnameditem (' opentime ')->value;
$t 1=substr ($t 1,-9);
Kjdata ($t 2,1, $t 1, $t 3);
}
function Kjdata () {
echo Join (', ', Func_get_args ()), Php_eol;
}
function Curl_get ($durl) {
$cookiejar = Realpath (' cookie.txt ');
$t = Parse_url ($durl);
$ch = Curl_init ();
curl_setopt ($ch, Curlopt_url, $durl);
curl_setopt ($ch, curlopt_timeout,5);
curl_setopt ($ch, Curlopt_ssl_verifypeer, 0);
curl_setopt ($ch, curlopt_useragent, $_server[' http_user_agent ');
curl_setopt ($ch, Curlopt_referer, "http://$t [host]/");
curl_setopt ($ch, Curlopt_cookiejar, $cookiejar);
curl_setopt ($ch, curlopt_returntransfer,1);
curl_setopt ($ch, curlopt_followlocation, true);
$r = curl_exec ($ch);
Curl_close ($ch);
return $r;
}
5,9,6,4,2, 1, 140421023, 2014-04-21 01:55:30
7,6,4,2,4, 1, 140421022, 2014-04-21 01:50:30