Hi I am a beginner programmer tyring to use TXMLparser with Delphi to just read a small xml file so I can understand how they work.
I have the following structure in xml file 'parser.xml' ;
<rule>
<alert>priority 3</alert>
<desc> </desc>
<action>beep</action>
</rule>
And I have the following code in delphi
VAR
Parser : TXmlParser;
rule, alert: string;
i:integer;
BEGIN
Parser := TXmlParser.Create;
Parser.Normalize := TRUE;
Parser.LoadFromFile ('c:\parser.xml');
Parser.StartScan;
WHILE Parser.Scan DO
CASE Parser.CurPartType OF
ptStartTag,
ptEmptyTag :
For i:=0 TO Parser.CurAttr.Count-1 Do
Begin
rule :=Parser.CurAttr.rule (i);
alert :=Parser.CurAttr.alert (i);
ptContent,
ptCData : // Process Parser.CurContent field here
ptEndTag : // Process End-Tag here (Parser.CurName)
ptPI : // Process PI here
// (Parser.CurName is the target, Parser.CurContent)
END;
Parser.Free;
end.
I dont understand where, and with what syntax (e.g. or 'rule' or rule) I am to enter in the xml tags. I obtained the base of the code from the XML website, but the FOR loop is mine.. Seems to work ok but rule and alert come back as undeclared identifiers, even though they are set in VAR
Any help on where to enter and how to enter the tags and why identifiers arent recognised would be appreciated.
Thanks