此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
楼主【simon803】截止到2008-07-03 13:59:20的历史汇总数据(不包括此帖):
发帖的总数量:61 发帖的总分数:740
结贴的总数量:52 结贴的总分数:620
无满意结贴数:26 无满意结贴分:651
未结的帖子数:9 未结的总分数:120
结贴的百分比:85.25 % 结分的百分比:83.78 %
无满意结贴率:50.00 % 无满意结分率:105.00%
楼主加油
楼主【simon803】截止到2008-07-03 13:59:20的历史汇总数据(不包括此帖):
发帖的总数量:61 发帖的总分数:740
结贴的总数量:52 结贴的总分数:620
无满意结贴数:26 无满意结贴分:651
未结的帖子数:9 未结的总分数:120
结贴的百分比:85.25 % 结分的百分比:83.78 %
无满意结贴率:50.00 % 无满意结分率:105.00%
楼主加油
解决方案 »
- 跪求,PHP如何连接到Lotus notes中取数据,和利用PHP发邮件(在Lotus notes邮件服务器)
- 为什么我连不到数据库MySQL?
- 攻击discuz论坛的一个设想
- 初学者。。。大家帮忙了。。
- PHP从数据库中提取出来的数据如何写入在线编辑器问题?
- 大家能不能提供一些项目做参考呢?以便初学者有一个学习的方向和动力
- session和cookie的计数器
- 急需linux下用php写的webmail,急……
- 求教 一个框架结构的左右两边同时改变的问题
- 紧急高分求救---SOS!!!!!!
- PHP+MySQL的不能插入和修改中文的问题
- 有谁知道php如何获取单选按钮的值和复选框所在行的记录?
$objH -> init("http://www.webxml.com.cn/WebServices/ChinaStockWebService.asmx/getStockInfoByCode?theStockCode=sh000001");$html = $objH -> DownloadToString();$stringDOM = new DOMDocument();$html = utf8_encode(html_entity_decode( $html,ENT_QUOTES));try{
@$stringDOM->loadXML($html);
}
catch(Exception $e){
//print_r($e);
}
$string = $stringDOM->getElementsByTagName('$string');
获取远程的XML文件,再解析XML就行了。
<?xml version = "1.0" ?>
<misc_command version="1.5">
<command_name>provision </command_name>
<command_data_block>
<action_id>1 </action_id>
<service_id>01112233 </service_id>
<mid>00148888888888 </mid>
<mobile_id>13999998888 </mobile_id>
<access_mode>1 </access_mode>
<access_mode>2 </access_mode>
<access_mode>3 </access_mode>
</command_data_block>
</misc_command>
XML;
$x = simplexml_load_string($xml);
//$x = simplexml_load_string(file_get_content(URL));
print_r($x); out:
SimpleXMLElement Object
(
[@attributes] => Array
(
[version] => 1.5
) [command_name] => provision
[command_data_block] => SimpleXMLElement Object
(
[action_id] => 1
[service_id] => 01112233
[mid] => 00148888888888
[mobile_id] => 13999998888
[access_mode] => Array
(
[0] => 1
[1] => 2
[2] => 3
) ) ) 明白了吧,注意文件的编码一致!!
<?xml version = "1.0" ?>
<misc_command version="1.5">
<command_name>provision </command_name>
<command_data_block>
<action_id>1 </action_id>
<service_id>01112233 </service_id>
<mid>00148888888888 </mid>
<mobile_id>13999998888 </mobile_id>
<access_mode>1 </access_mode>
<access_mode>2 </access_mode>
<access_mode>3 </access_mode>
</command_data_block>
</misc_command>
XML;
$x = simplexml_load_string($xml);
//$x = simplexml_load_string(file_get_content(URL));
print_r($x); out:
SimpleXMLElement Object
(
[@attributes] => Array
(
[version] => 1.5
) [command_name] => provision
[command_data_block] => SimpleXMLElement Object
(
[action_id] => 1
[service_id] => 01112233
[mid] => 00148888888888
[mobile_id] => 13999998888
[access_mode] => Array
(
[0] => 1
[1] => 2
[2] => 3
) ) )
注意文件的编码一致!!
<?php
#usage:
//$r = new HTTPRequest('http://www.php.net');
//echo $r->DownloadToString();class HTTPRequest
{
var $_fp; // HTTP socket
var $_url; // full URL
var $_host; // HTTP host
var $_protocol; // protocol (HTTP/HTTPS)
var $_uri; // request URI
var $_port; // port
// scan url
function _scan_url()
{
$req = $this->_url;
$pos = strpos($req, '://');
$this->_protocol = strtolower(substr($req, 0, $pos));
$req = substr($req, $pos+3);
$pos = strpos($req, '/');
if($pos === false)
$pos = strlen($req);
$host = substr($req, 0, $pos);
//echo $host;exit;
if(strpos($host, ':') !== false)
{
list($this->_host, $this->_port) = explode(':', $host);
}
else
{
$this->_host = $host;
$this->_port = ($this->_protocol == 'https') ? 443 : 80;
}
$this->_uri = substr($req, $pos);
//echo $this->_uri;exit;
if($this->_uri == '')
$this->_uri = '/';
}
// constructor
function HTTPRequest()
{
} //init
function init($url)
{
$this->_url = $url;
$this->_scan_url();
}
// download URL to string
function DownloadToString()
{
$crlf = "\r\n";
$response="";
// generate request
$req = 'GET ' . $this->_uri . ' HTTP/1.0' . $crlf
. 'Host: ' . $this->_host . $crlf
. $crlf;
// fetch
$this->_fp = fsockopen(($this->_protocol == 'https' ? 'ssl://' : '') . $this->_host, $this->_port);
fwrite($this->_fp, $req);
while(is_resource($this->_fp) && $this->_fp && !feof($this->_fp))
$response .= fread($this->_fp, 1024);
fclose($this->_fp);
// split header and body
$pos = strpos($response, $crlf . $crlf);
if($pos === false)
return($response);
$header = substr($response, 0, $pos);
$body = substr($response, $pos + 2 * strlen($crlf));
// parse headers
$headers = array();
$lines = explode($crlf, $header);
foreach($lines as $line)
if(($pos = strpos($line, ':')) !== false)
$headers[strtolower(trim(substr($line, 0, $pos)))] = trim(substr($line, $pos+1));
// redirection?
if(isset($headers['location']))
{
$http = new HTTPRequest($headers['location']);
return($http->DownloadToString($http));
}
else
{
return($body);
}
}
}
?>
foreach($dom as $k=>$v)
{
echo $v."<br/>";
}
您输出的结果是:
sh000001
涓婅瘉鎸囨暟
2008-07-04 09:52:33
2695.495
2703.529
2691.207
-8.03
2677.979
2710.534
-0.30%
90500.33如果要在输出前加文字该怎么改,比如这样输出:
代码:sh000001
名称:涓婅瘉鎸囨暟
时间:2008-07-04 09:52:33
..............