正在线等你呢,我想把WEBSERVICE返回的XML分解出来,请看一下,分归你(100分)

  • 主题发起人 主题发起人 czly
  • 开始时间 开始时间
C

czly

Unregistered / Unconfirmed
GUEST, unregistred user!
<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>
<string xmlns=&quot;http://www.webserviceX.NET&quot;><?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?>
<CurrentWeather>
<Location>Beijing, China (ZBAA) 39-56N 116-17E 55M</Location>
<Time>Nov 17, 2006 - 02:00 AM EST / 2006.11.17 0700 UTC</Time>
<Wind> from the E (090 degrees) at 4 MPH (4 KT):0</Wind>
<Visibility> 3 mile(s):0</Visibility>
<SkyConditions> overcast</SkyConditions>
<Temperature> 50 F (10 C)</Temperature>
<DewPoint> 39 F (4 C)</DewPoint>
<RelativeHumidity> 66%</RelativeHumidity>
<Pressure> 30.21 in. Hg (1023 hPa)</Pressure>
<Status>Success</Status>
</CurrentWeather></string>
返回结果是这样的,是国外的一个天气预报的服务
我想将各个值分别取出来添加到CLIENTDATASET中或分别显示在MEMO里
以前有本组件大全里介绍过用XMLMAPPER来做不过忘记了,用其它访问怎么做呢?
 
怎样取到
Location呢
 
str := IWeather.GetWeather(edtCity.Text,edtCountry.Text);
我想把未解析的XML内容由WEBSERVICE传给TXMLDocument,再从其中分解出值来,但是不知道如何写
 
哪位能贴出个道理来呀?[:)]
 
switch from current encoding to specified encoding not supported
line 1....encoding=&quot;utf-16&quot; process stopped
改成这样就报个地址错误
// XMLDocument1.Encoding := 'UTF-8';
代码是这样写的
var
IWeather: GlobalWeatherSoap;
XMLDocument1: TXMLDocument;
I, J , NodeCount: Integer;
NodeList, Attributes : IXMLNodeList;
RecName : widestring;
begin
IWeather := (HTTPRIO1 as GlobalWeatherSoap);
XMLDocument1:= TXMLDocument.Create(self);
// XMLDocument1.Encoding := 'UTF-8';
XMLDocument1.XML.Text := IWeather.GetWeather(edtcity.Text,edtcountry.Text);
XMLDocument1.Active := true;
NodeList := XMLDocument1.DocumentElement.ChildNodes;
NodeCount := NodeList.Count;
for i := 0 to NodeCount-1 do
begin
RecName := NodeList.Nodes.NodeName;
RecName := RecName +'&Oacute;&ETH;&Ecirc;&ocirc;&ETH;&Ocirc;'+#13+#10;
Attributes := NodeLIst.Nodes.AttributeNodes;
for j := 0 to Attributes.Count - 1 do
begin
RecName := ' '+RecName + ' ' + Attributes.Nodes[j].Text + #131#10;
RecName := ' '+RecName + ' ' + Attributes.Nodes[j].Text + #131#10;
Memo1.Lines.Add(RecName);
end;
end;
XMLDocument1.Active := false;
end;
 
后退
顶部