你要学学xsl的。
比如这样
procedure TDownList.Down();
var n,m,i,endm:integer;
tmpXml:IxmldomDocument;
tmpNode,Node2:IxmldomNodeList;
begin
try
CoInitialize(nil);
tmpxml := CreateOLEObject('Microsoft.XmlDom') as IXMLDOMDocument;
tmpxml.async :=false;
tmpxml.load(Url);
while tmpxml.readyState<>4do
begin
//i:=0;
end;
if tmpxml.parseError.errorCode <> 0 then
begin
CtGoBack:=tmpXml.parseError.url+'#'+tmpxml.parseError.reason+'#'+tmpxml.parseError.srcText;
Exit;
end;
tmpNode:=tmpXml.selectNodes('Forum/Topics/Topic');
//这里就是查询语句了。也可以加上查询条件的。
n:=tmpNode.length;
for i:=1 to ndo
begin
Node2:=tmpNode.item[i-1].childNodes;
endm:=Node2.length;
if (endm>7) then
endm:=7;
for m:=1 to endmdo
begin
aryList[i,m]:=node2.item[m-1].text;
end;
end;
finally
tmpxml:=nil;
CoUninitialize();
end;
end;
下面这个就是条件查询了 可以用and 或 | 来连接多个条件的。
xmlobj:= CreateOLEObject('Microsoft.XmlDom') as IXMLDOMDocument;
xmlobj.async := false;
xmlobj.load(tmp);
if xmlobj.parseError.errorCode <> 0 then
begin
showmessage('焦点帖子装入出错');
Exit;
end;
tmpNode:=xmlobj.documentElement.lastChild;
for i:=0 to CheckListbox1.Count-1do
begin
if checkListBox1.Checked=true then
begin
xSql:='/CSDN/Focus[@ID="'+ CheckListBox1.Items +'"]';
tmpNode2:=tmpNode.selectSingleNode(xSql);
if tmpNode2<>nil then
begin
xmlobj.documentElement.removeChild(tmpNode2);
end;
end;
end;
xmlobj.save(tmp);