2
0

reducexml.pp 627 B

12345678910111213141516171819202122232425262728293031323334353637
  1. program reducexml;
  2. {$mode objfpc}
  3. {$h+}
  4. uses cwstring,SysUtils,classes,DOM,xmlutils,xmlread,xmlwrite;
  5. Var
  6. D : TXMLDocument;
  7. S : TFileStream;
  8. W : TDOMWriter;
  9. FN : String;
  10. begin
  11. if paramCount=0 then
  12. begin
  13. Writeln('Usage : reducexml infile [outfile]');
  14. halt(1);
  15. end;
  16. ReadXMLFile(D,ParamStr(1));
  17. FN:=ParamStr(2);
  18. if FN='' then
  19. FN:=ChangeFileExt(ParamStr(1),'-new.xml');
  20. W:=nil;
  21. S:=TFileStream.Create(FN,fmCreate);
  22. try
  23. W:=TDOMWriter.Create(S,D);
  24. W.IndentSize:=1;
  25. // W.Canonical:=True;
  26. W.UseTab:=True;
  27. W.WriteNode(D);
  28. Finally
  29. W.Free;
  30. S.Free;
  31. end;
  32. end.