WebServices获取股票实时信息2.1.5 getStockInfoByCode
获得中国股票及时行情
input:theStockCode = 股票代号
POST /WebServices/ChinaStockWebService.asmx HTTP/1.1Host: www.webxml.com.cnContent-Type: text/xml; charset=utf-8Content-Length: lengthSOAPAction: "http://WebXml.com.cn/getStockInfoByCode" <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <getStockInfoByCode xmlns="http://WebXml.com.cn/"> <theStockCode>string</theStockCode> </getStockInfoByCode> </soap:Body></soap:Envelope>返回的值一个一维字符串数组 String(24),结构为:String(0)股票代号、String(1)股票名称、String(2)行情时间、String(3)最新价(元)、String(4)昨收盘(元)、String(5)今开盘(元)、String(6)
用Delphi做的程序,
procedure TForm1.Button3Click(Sender: TObject);
var
doc,url:Olevariant ;
stt:string;
begin   stt:='601857' ;
   url:='http://hq.sinajs.cn/list=sh'+stt ;//或者一个有实际意义的url
   WebBrowser1.Navigate('http://www.webxml.com.cn/WebServices/ChinaStockWebService.asmx/getStockInfoByCode?theStockCode=sh000010');//这样就激活了!
   //webBrowser1.Navigate('http://www.163.com/');
end;
也能显示数据如下:  <?xml version="1.0" encoding="utf-8" ?> 
- <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://WebXml.com.cn/">
  <string>sh000010</string> 
  <string>上证180</string> 
  <string>2010-07-19 10:07:37</string> 
  <string>5658.588</string> 
  <string>5653.425</string> 
  <string>5601.703</string> 
  <string>5.16</string> 
  <string>5586.928</string> 
  <string>5664.749</string> 
  <string>0.09%</string> 
  <string>55127.57</string> 
  <string>547374.6229</string> 
  <string /> 
  <string /> 
  <string /> 
  <string /> 
  <string /> 
  <string /> 
  <string /> 
  <string /> 
  <string /> 
  <string /> 
  <string /> 
  <string /> 
  <string /> 
  </ArrayOfString>
我现在的目的是在Delphi中定义一个数组string[50]
用上面的数据给数组赋值,怎么做啊。

解决方案 »

  1.   

    读取每一组<string>5653.425</string>,有值你就取,没值就跳过
      

  2.   

    怎么读取啊,就是不知道怎么代表,如
    string[1]:=?后面的问号用什么代表啊,等于谁啊
      

  3.   

    用xml来存,遍历各个元素即可,好像有个叫xmldocument的对象,你跟她谈谈
      

  4.   

    能具体些吗,Delphi倒是能做到
      

  5.   

    先把<string />替换为<string></string>
    然后使用getTag(sxml,'<string>','</string>')取得其间的内容即可
      

  6.   

    这个属于读取xml内容的问题吧
      

  7.   

    在網上找一下如何讀取XML的數據問題......