|
|
|
|
|
для: Atheist
(21.03.2008 в 14:23)
| | SimpleXMLElement Object
(
[resultcode] => 0
[itemlist] => SimpleXMLElement Object
(
[item] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[name] => АГРОХИМБАНК, ГОЛОВНОЙ ОФИС
[id] => XBTM
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[name] => АГРОХИМБАНК, ДО ОТД. #ЩЕЛКОВО#
[id] => YFZJ
)
)
чтобы добраться до
я делаю так.
foreach ($xml->xpath('//response') as $response) {
echo $result_code = $response->resultcode;
}
|
а как добраться до
[@attributes] => Array
(
[name] => АГРОХИМБАНК, ГОЛОВНОЙ ОФИС
[id] => XBTM
)
|
два дня уже голову ломаю. | |
|
|
|
|
|
|
|
для: Atheist
(21.03.2008 в 11:59)
| | - | |
|
|
|
|
|
|
|
для: streloc
(21.03.2008 в 13:39)
| | Потом будет не проще и медленней. | |
|
|
|
|
|
|
|
для: Atheist
(21.03.2008 в 13:28)
| | нет слишком долго и непонятно. Я думаю проще PHP функциями или регулярными выражениями разобрать
echo $cod = strchr($cod,"id=");
выводит
id="259832936" status ="150" sum="1.00" /> | |
|
|
|
|
|
|
|
для: streloc
(21.03.2008 в 13:15)
| | Это заголовки. Я так понимаю, там должен быть XML-документ. | |
|
|
|
|
|
|
|
для: Atheist
(21.03.2008 в 13:12)
| | HTTP/1.1 200 OK Date: Fri, 21 Mar 2008 10:19:55 GMT Server: Apache Content-Length: 142 Vary: Accept-Encoding,User-Agent Connection: close Content-Type: text/xml;charset=UTF-8 Content-Language: ru 0 | |
|
|
|
|
|
|
|
для: streloc
(21.03.2008 в 13:09)
| | Просто дай получаемый контент ($cod). | |
|
|
|
|
|
|
|
для: Atheist
(21.03.2008 в 13:03)
| | правильно. Это значит неверный пароль. Я же не выложу сюда пароль. | |
|
|
|
|
|
|
|
для: streloc
(21.03.2008 в 12:55)
| | var_export $xml у меня такой:
SimpleXMLElement::__set_state(array(
'resultcode' => '150',
)) | |
|
|
|
|
|
|
|
для: HaJIuBauKa
(21.03.2008 в 12:52)
| |
<?
ini_set('display_errors', 1);
error_reporting( E_ALL );
$URL="http://mobw.ru/term2/xmlutf.jsp";
function HTTP_Post($URL,$data, $referrer, $phone) {
global $phone;
$URL_Info=parse_url($URL);
if($referrer=="")
$referrer=$_SERVER["SCRIPT_URI"];
$data_string= ('<?xml version="1.0" encoding="utf-8"?>
<request>
<protocol-version>4.00</protocol-version>
<request-type>33</request-type>
<extra name="password">11111111</extra>
<terminal-id>1111</terminal-id>
<extra name="serial">1111</extra>
<bills-list>
<bill id="259832936" />
</bills-list>
</request>
');
if(!isset($URL_Info["port"]))
$URL_Info["port"]=80;
$request.="POST ".$URL_Info["path"]." HTTP/1.1\n";
$request.="Host: ".$URL_Info["host"]."\n";
$request.="Referer: $referer\n";
$request.="Content-type: application/x-www-form-urlencoded\n";
$request.="Content-length: ".strlen($data_string)."\n";
$request.="Connection: close\n";
$request.="\n";
$request.=$data_string."\n";
$fp = fsockopen($URL_Info["host"],$URL_Info["port"]);
fputs($fp, $request);
while(!feof($fp)) {
$result .= fgets($fp, 528);
}
fclose($fp);
return $result;
}
$cod = HTTP_Post($URL);
$code = strchr($cod,"<response>");
$code = str_replace("result-code","resultcode",$code);
$code = str_replace("bills-list","billslist",$code);
$code = str_replace("attributes","attributes",$code);
$xml = simplexml_load_string($code);
foreach ($xml->xpath('//response') as $response) {
$result_code = $response->resultcode;
}
echo '<pre>', var_export($xml, true), '</pre>';
echo $xml->bill->{'@attributes'}['status'];
echo $xml->billslist->bill->{'@attributes'}['status'];
echo $xml->billslist->bill->attributes['status'];
?>
|
| |
|
|
|
|