delphi中怎么读取XML的 CDATA 节点数据
2个回答
展开全部
function decodexml(filename: string):boolean;
var
ncount,i,j,k,m,n:integer;
nodeList,nodewp: IXMLNodeList;
node,nodejbxx,row,wpxx: IXMLNode;
datainfo:TBarInfo;
cp:array of TCpInfo;
oldqydm,cqydm:string;
breload:Boolean;
begin
breload:=false;
result:=false;
try
XMLDocument1.FileName :=filename;
XMLDocument1.Active := True; {激活}
nodeList := XMLDocument1.DocumentElement.ChildNodes;
for I := 0 to nodeList.Count-1 do
begin
node:=nodeList[i];
if node.NodeName='aa' then
begin
datainfo.Qy.qymc:=node.ChildValues['a1'];
datainfo.Qy.lxdm:=node.ChildValues['a2'];
datainfo.Qy.qydm:=node.ChildValues['a3'];
datainfo.Qy.zzdm:=node.ChildValues['a4'];
end
else
if node.NodeName='bb' then
begin
nodewp:=node.ChildNodes;
if nodewp.Count>0 then
begin
for k := 0 to nodewp.Count-1 do
begin
row:=nodewp[k];
cp[k].Cplb:=row.ChildNodes.Nodes['b1'].Text;
cp[k].Cpjb:=row.ChildNodes.Nodes['b2'].Text;
cp[k].Cpxh:=row.ChildNodes.Nodes['b3'].Text;
cp[k].cpmc:=row.ChildNodes.Nodes['b4'].Text;
cp[k].zyl:=row.ChildNodes.Nodes['b5'].Text;
cp[k].dw:=row.ChildNodes.Nodes['b6'].Text;
application.ProcessMessages;
end;
end;
end;
end;
var
ncount,i,j,k,m,n:integer;
nodeList,nodewp: IXMLNodeList;
node,nodejbxx,row,wpxx: IXMLNode;
datainfo:TBarInfo;
cp:array of TCpInfo;
oldqydm,cqydm:string;
breload:Boolean;
begin
breload:=false;
result:=false;
try
XMLDocument1.FileName :=filename;
XMLDocument1.Active := True; {激活}
nodeList := XMLDocument1.DocumentElement.ChildNodes;
for I := 0 to nodeList.Count-1 do
begin
node:=nodeList[i];
if node.NodeName='aa' then
begin
datainfo.Qy.qymc:=node.ChildValues['a1'];
datainfo.Qy.lxdm:=node.ChildValues['a2'];
datainfo.Qy.qydm:=node.ChildValues['a3'];
datainfo.Qy.zzdm:=node.ChildValues['a4'];
end
else
if node.NodeName='bb' then
begin
nodewp:=node.ChildNodes;
if nodewp.Count>0 then
begin
for k := 0 to nodewp.Count-1 do
begin
row:=nodewp[k];
cp[k].Cplb:=row.ChildNodes.Nodes['b1'].Text;
cp[k].Cpjb:=row.ChildNodes.Nodes['b2'].Text;
cp[k].Cpxh:=row.ChildNodes.Nodes['b3'].Text;
cp[k].cpmc:=row.ChildNodes.Nodes['b4'].Text;
cp[k].zyl:=row.ChildNodes.Nodes['b5'].Text;
cp[k].dw:=row.ChildNodes.Nodes['b6'].Text;
application.ProcessMessages;
end;
end;
end;
end;
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |