If I have two string of xml1 and xml2 which both represent xml in the same format. What is the fastest way to combine these together? The format is not important, but I ju
If you can guarantee this format you can combine them by doing string manipulation:
This should be the fastest way since no parsing is needed.
const string RelevantTag = "AllNodes";
string xml1 = File.ReadAllText(xmlFile1);
xml1 = xml1.Substring(0, xml.LastIndexOf("" + RelevantTag + ">"));
string xml2 = File.ReadAllText(xmlFile2);
xml2 = xml2.Substring(xml.IndexOf("<" + RelevantTag + ">") + "<" + RelevantTag + ">".Length, xml1.Length);
File.WriteAllText(xmlFileCombined, xm1 + xml2);
That said I would always prefer the safe way to the fast way.