Guest User

Untitled

a guest
Oct 20th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. private
  2. { Private declarations }
  3. ImportMsg : Boolean; //Define se mostra Mensagem de carregamento
  4. function CheckFile():Boolean;
  5. procedure Import();
  6.  
  7. function TFrmMain.CheckFile(): Boolean;
  8. var s: String;
  9. begin
  10. Result:=True;
  11.  
  12. if EdtPath.Text = '' then
  13. begin
  14. s:='Por favor selecione um caminho de arquivo válido!';
  15. Result:=False;
  16. end;
  17. if not Result then MessageDlg(s,mtWarning,[mbOK], 0);
  18. end;
  19.  
  20. procedure TFrmMain.Import();
  21. var Node, Node2: IXMLNode;
  22. i,count: integer;
  23. li : TListItem;
  24. begin
  25. xmldoc.FileName := EdtPath.Text;
  26. xmldoc.Active := True;
  27. Node := xmldoc.DocumentElement;
  28. //Se for encontrado um arquivo XML valido
  29. if Node.NodeName = 'headlines' then
  30. begin
  31. Node2 := Node.ChildNodes.FindNode('phrases');
  32. count := 0;
  33. ProgressXml.Min := 0;
  34. ProgressXml.Max := Node.ChildNodes.Count;
  35. LstvTemplates.Clear;
  36. for i := 0 to Node.ChildNodes.Count -1 do
  37. begin
  38. ProgressXml.Position := count;
  39. li := LstvTemplates.Items.Add;
  40. li.Caption := Node2.ChildNodes.FindNode('cod').Text;
  41. li.SubItems.Add (Node2.ChildNodes.FindNode('nome').Text);
  42. li.SubItems.Add (Node2.ChildNodes.FindNode('sobrenome').Text);
  43. li.SubItems.Add (Node2.ChildNodes.FindNode('telefone').Text);
  44. li.SubItems.Add (Node2.ChildNodes.FindNode('obs').Text);
  45. count := count + 1;
  46. Node2 := Node2.NextSibling;
  47. end;
  48. ProgressXml.Position := 0;
  49. EdtPath.Text := '';
  50.  
  51. if ImportMsg = True then
  52. MessageDlg('A Importação do Arquivo XML foi efetuada com sucesso!',mtInformation,[mbOK], 0);
  53. end
  54. else
  55. begin
  56. MessageDlg('Este não é o arquivo XML adequado ou válido!',mtWarning,[mbOK], 0);
  57. end;
  58. end;
Add Comment
Please, Sign In to add comment