XML: MSXML nie jest zainstalowany
Użycie tego kodu do uzyskania rss witryny. Ten kod działa poprawnie na moim komputerze i wielu innych komputerach. Ale na niektórych komputerach (Windows XP lub 7) pojawia się ten błąd:MSXML nie jest zainstalowany
Jak mogę rozwiązać ten problem? Co jest nie tak?
Oto kod:
procedure My_Thread.Execute;
var
http : tidhttp;
strm : tmemorystream;
str,sTitle, sDec ,er : string;
StartItemNode : IXMLNode;
ANode : IXMLNode;
XMLDoc : IXMLDocument;
begin
http := tidhttp.Create();
strm := tmemorystream.Create;
try
http.Get('http://www.sample.com/rss.xml',strm); //Download the RSS file
SetString(str,PANSIChar(strm.Memory),strm.Size);
XMLDoc := LoadXMLData(str);
StartItemNode := XMLDoc.DocumentElement.ChildNodes.First.ChildNodes.FindNode('item');
ANode := StartItemNode;
i := 0;
repeat
inc(i);
sTitle := ANode.ChildNodes['title'].Text;
sDec := ANode.ChildNodes['description'].Text;
Synchronize(procedure begin //Synchronize? I'm using threads
case I of
1: begin
main_frm.edit1.text := sTitle; //main_frm is my form
main_frm.edit2.text := sDec;
end;
2: begin
main_frm.edit3.text := sTitle;
main_frm.edit4.text := sDec;
end;
3: begin
main_frm.edit5.text := sTitle;
main_frm.edit6.text := sDec;
end;
end;
ANode := ANode.NextSibling;
end);
until ANode = nil;
http.Free;
strm.Free;
except
on E: Exception do
begin
er := e.Message;
Synchronize(procedure begin
ShowMessage(er);
end);
end;
end;
end;
Jak widzisz, używam wątków. WięcSynchronize
był potrzebny.