Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private
- { Private declarations }
- ImportMsg : Boolean; //Define se mostra Mensagem de carregamento
- function CheckFile():Boolean;
- procedure Import();
- function TFrmMain.CheckFile(): Boolean;
- var s: String;
- begin
- Result:=True;
- if EdtPath.Text = '' then
- begin
- s:='Por favor selecione um caminho de arquivo válido!';
- Result:=False;
- end;
- if not Result then MessageDlg(s,mtWarning,[mbOK], 0);
- end;
- procedure TFrmMain.Import();
- var Node, Node2: IXMLNode;
- i,count: integer;
- li : TListItem;
- begin
- xmldoc.FileName := EdtPath.Text;
- xmldoc.Active := True;
- Node := xmldoc.DocumentElement;
- //Se for encontrado um arquivo XML valido
- if Node.NodeName = 'headlines' then
- begin
- Node2 := Node.ChildNodes.FindNode('phrases');
- count := 0;
- ProgressXml.Min := 0;
- ProgressXml.Max := Node.ChildNodes.Count;
- LstvTemplates.Clear;
- for i := 0 to Node.ChildNodes.Count -1 do
- begin
- ProgressXml.Position := count;
- li := LstvTemplates.Items.Add;
- li.Caption := Node2.ChildNodes.FindNode('cod').Text;
- li.SubItems.Add (Node2.ChildNodes.FindNode('nome').Text);
- li.SubItems.Add (Node2.ChildNodes.FindNode('sobrenome').Text);
- li.SubItems.Add (Node2.ChildNodes.FindNode('telefone').Text);
- li.SubItems.Add (Node2.ChildNodes.FindNode('obs').Text);
- count := count + 1;
- Node2 := Node2.NextSibling;
- end;
- ProgressXml.Position := 0;
- EdtPath.Text := '';
- if ImportMsg = True then
- MessageDlg('A Importação do Arquivo XML foi efetuada com sucesso!',mtInformation,[mbOK], 0);
- end
- else
- begin
- MessageDlg('Este não é o arquivo XML adequado ou válido!',mtWarning,[mbOK], 0);
- end;
- end;
Add Comment
Please, Sign In to add comment