Edit: My (incomplete and very rude) translation of the XmlLite header is available on GitHub
What is the best way to easily combine massive XML documents in Delphi with MSXML without using the DOM? Should I use SAXReader and XMLWriter COM components and are there any good examples?
Conversion is a simple combination of all content elements from the root (Container) from a large number of large files (60 MB +) to one huge file (~ 1 GB).
<Container> <Contents /> <Contents /> <Contents /> </Container>
It works for me in the following C # code using XmlWriter and XmlReaders, but this should happen in the Delphi native process:
var files = new string[] { @"c:\bigFile1.xml", @"c:\bigFile2.xml", @"c:\bigFile3.xml", @"c:\bigFile4.xml", @"c:\bigFile5.xml", @"c:\bigFile6.xml" }; using (var writer = XmlWriter.Create(@"c:\HugeOutput.xml", new XmlWriterSettings{ Indent = true })) { writer.WriteStartElement("Container"); foreach (var inputFile in files) using (var reader = XmlReader.Create(inputFile)) { reader.MoveToContent(); while (reader.Read()) if (reader.IsStartElement("Contents")) writer.WriteNode(reader, true); } writer.WriteEndElement();
We already use the MSXML DOM in other parts of the system, and I do not want to add new components, if possible.
carlmon
source share