Hi
I am parsing an XML file and storing the results in a record, but am having some trouble.
Im trying to store the results (content of my XML tags) into the fields of my record..
My record (at the moment there is only 1 set of XML elements). I think that the Parser.curconten is causing the problem...
Type
TXMLAlert=Record
alert, desc, action:string;
end;
Var
MyXMLAlert:TXMLAlert;
MyXMLAlert.alert:=Parser.CurContent
MyXMLAlert.desc:=Parser.CurContent
MyXMLAlert.action:=Parser.CurContent
The following is my parser code;
procedure ProcessXML();
var
Parser : TXmlParser;
rule, alert: string;
i:integer;
memo1:Tmemo;
begin
Parser := TXmlParser.Create;
Parser.Normalize := TRUE;
Parser.LoadFromFile ('c:\parser.xml');
Parser.StartScan;
while Parser.Scan do
case Parser.CurPartType of
ptStartTag,
ptEmptyTag : Form1.Memo1.Lines.Add ('New Element: ' + Parser.CurName);
ptContent : Form1.Memo1.Lines.Add ('Content of Element ' +
Parser.Curname + ':' + Parser.CurContent);
end;
Parser.Free;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ProcessXML();
end;
end.
Program parser fine and the content of tags is displayed in memo1... Any ideas why the record is not picking up the results of content? Thanks, Lazerspewpew