|
안녕하세요 만해 입니다.
요즘 델 소스 가져 와서 빌더에서 사용하는 거 하고 있는데요
이게 잘 안되네요
var
s:string;
j,i:integer;
obj:TObject;
HTMLTag:THTMLTag;
HTMLParam:THTMLParam;
begin
Memo1.Clear;
HTMLParser:=THTMLParser.Create;
HTMLParser.Execute;
for i:= 1 to HTMLParser.parsed.count do
begin
obj:=HTMLParser.parsed[i-1];
// <- 여기 바로 위부분을
//if ( TObject* obj = dynamic_cast<TList*>(TList*)HTMLParser->Parsed[i-1]; //new TList;
// 이렇게 했는데 에러가 나고요
// obj = (TList*)HTMLParser->Parsed[i-1]; <- 이렇게도 해봤는데 안되네요
if obj.classtype=THTMLTag then
begin
HTMLTag:=THTMLTag(obj); // <- 그리고 이부분은 어떻게 해야 하는지 잘 모르겠어요
s:='TAG: <'+HTMLTag.Name;
if HTMLTag.Params.count=0 then memo1.Lines.add(s+'>')
else
begin
memo1.Lines.add(s);
for j:= 1 to HTMLTag.Params.count do
begin
HTMLParam:=HTMLTag.Params[j-1];
s:=' P: '+HTMLParam.key;
if HTMLParam.value<>'' then s:=s+'=>'+HTMLParam.value;
if j=HTMLTag.Params.count then s:=s+'>';
memo1.Lines.add(s);
end;
end;
end;
if obj.classtype=THTMLText then memo1.Lines.add('TXT: '+THTMLText(obj).Line);
end;
Button2.Enabled:=true;
end;
그리고 제가 사용한 객체의 형태 입니다.
type THTMLParam = class
private
fRaw:string;
fKey:string;
fValue:string;
procedure SetKey(Key:string);
public
constructor Create;
destructor Destroy; override;
published
property Key:string read fKey write SetKey;
property Value:string read fValue;
property Raw:string read fRaw;
end;
type THTMLTag = class
private
fName:string;
fRaw:string;
procedure SetName(Name:string);
public
Params:TList;
constructor Create;
destructor Destroy; override;
published
property Name:string read fName write SetName;
property Raw:string read fRaw;
end;
type THTMLText = class
private
fLine:String;
fRawLine:string;
procedure SetLine(Line:string);
public
constructor Create;
destructor Destroy; override;
published
property Line:string read fLine write SetLine;
property Raw:string read fRawLine;
end;
type THTMLParser = class(TObject)
private
Text:string;
Tag:string;
isTag:boolean;
procedure AddText;
procedure AddTag;
public
Parsed:TList;
Lines:TStringlist;
constructor Create;
destructor Destroy; override;
procedure Execute;
published
end;
원래는 MS HTML 객체를 이용해서 할려고 했는데
COM을 몰라서 그냥 이걸로 하고 있어요 고수님들의 도움 바랍니다.
|