先给代码,程序如下:
Function TFileOperation.XMLToList(FileName:string):TList;
var
temp:TList;
Root,Parent,Child:IXMLNode;
Doc:TDocs;
XML:TXMLDocument;
begin
temp.Create;
XML.LoadFromFile(FileName);
Root:=XML.DocumentElement;
Parent:=Root.ChildNodes.First;
while (Parent<>NIL) do
begin
Child:=Parent.ChildNodes.First;
while (Child<>NIL) do
begin
Doc.Create;
Doc.Name:=Child.NodeName;
Doc.FileName:=Child.Attributes['FileName'];
Doc.UpdateTime:=Child.Attributes['UpDateTime'];
Doc.NetPath:=Child.Attributes['NetPath'];
Doc.FileSize:=Child.Attributes['FileSize'];
temp.Add(Doc);
Child:=Child.NextSibling;
end;
Parent:=Parent.NextSibling;
end;
result:=temp;
end;这样一段程序为什么编译的话编译器显示没有任何问题。但是如果运行的话,DELPHI就会显示“Project Project1.exe raised exception class EClassNotFound with message "class TXMLDocument not found",process stoped,use step or run to continue" ?
我使用的DELPHI 7。希望大大们帮小弟快点解决这个问题,谢谢了
Function TFileOperation.XMLToList(FileName:string):TList;
var
temp:TList;
Root,Parent,Child:IXMLNode;
Doc:TDocs;
XML:TXMLDocument;
begin
temp.Create;
XML.LoadFromFile(FileName);
Root:=XML.DocumentElement;
Parent:=Root.ChildNodes.First;
while (Parent<>NIL) do
begin
Child:=Parent.ChildNodes.First;
while (Child<>NIL) do
begin
Doc.Create;
Doc.Name:=Child.NodeName;
Doc.FileName:=Child.Attributes['FileName'];
Doc.UpdateTime:=Child.Attributes['UpDateTime'];
Doc.NetPath:=Child.Attributes['NetPath'];
Doc.FileSize:=Child.Attributes['FileSize'];
temp.Add(Doc);
Child:=Child.NextSibling;
end;
Parent:=Parent.NextSibling;
end;
result:=temp;
end;这样一段程序为什么编译的话编译器显示没有任何问题。但是如果运行的话,DELPHI就会显示“Project Project1.exe raised exception class EClassNotFound with message "class TXMLDocument not found",process stoped,use step or run to continue" ?
我使用的DELPHI 7。希望大大们帮小弟快点解决这个问题,谢谢了
解决方案 »
- 那位高手能详细介绍一下delphi的idftpserver控件使用方法。
- 我知道这样的问题100分是太少了,十万火急:兄弟们帮帮想想,我感觉是个十分困难的问题,与服务器的连接......
- 如何在一个string中查找其中的汉字?
- 最近我研究 全文搜索引擎的心得(三) 跟大家说个笑话
- 某文件存在于电脑硬盘里,delphi程序运行时如何打开此文件?
- 请问有关数据库三层架构的问题
- 这是为什么我做的MIS系统为什么程序退出总是出现这个对话框??
- 为何下面的程序执行的时候,edit1\edit2的现实没有任何变化
- 大伙来侃侃RAVE Report!UP也送分!
- 一个最初级的问题
- Delphi擂台赛新鲜出炉
- 想用OLE2方式使用OUTLOOK,请问:
Function TFileOperation.XMLToList(FileName:string):TList;
var
temp:TList;
Root,Parent,Child:IXMLNode;
Doc:TDocs;
XML:TXMLDocument;
begin
temp.Create;
XML.LoadFromFile(FileName); //你的XML变量都没有创建,怎么能用呢
Root:=XML.DocumentElement;
Parent:=Root.ChildNodes.First;
while (Parent<>NIL) do
begin
Child:=Parent.ChildNodes.First;
while (Child<>NIL) do
begin
Doc.Create;
Doc.Name:=Child.NodeName;
Doc.FileName:=Child.Attributes['FileName'];
Doc.UpdateTime:=Child.Attributes['UpDateTime'];
Doc.NetPath:=Child.Attributes['NetPath'];
Doc.FileSize:=Child.Attributes['FileSize'];
temp.Add(Doc);
Child:=Child.NextSibling;
end;
Parent:=Parent.NextSibling;
end;
result:=temp;
end;
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, UrlMon, xmldom, XMLIntf, msxmldom, XMLDoc, StdCtrls, ComCtrls,
xercesxmldom;然后我在 XML.LoadFromFile(FileName); 前面加了一行语句:XML.Create(nil);
但是问题依然存在。
TDOC是我自己定义的。还有就是我编译都通过了,但是就是按F9的时候出现问题
XML.Create(nil);换成
XML := TXMLDocument.Create(nil);还记得最后一定要XML.Free啊。有创建就要有释放。
temp := TList.Create;最后也要调用temp.Free释放掉对象。学一下Delphi语法才是最重要的。
但是,我按照您的意见改过来了.
temp := TList.Create;
XML:=TXMLDocument.Create(nil);
还是有我说的哪个问题.这是什么问题呢?
ActiveX类的动态建立
使用CoInit函数就行的_____________________
http://lysoft.7u7.net
还是用OpenXML比较,虽然程序会大很多。
昨天竟打不开Blog,想发也发不了,气死人了。
中午再发吧。