If the size and the structure of the files is identical, you could perhaps the files process one string line at a time instead of using XElement or XMLDocument classes. But, I suppose this will only succeed with rather simple XML files:
string pattern = @">.+\s?.*</";
//path = <your A.xml file>
//destPath = <your B.xml file>
string[] source = File.ReadAllLines(path);
string[] dest = File.ReadAllLines(destPath);
Regex regex = new Regex(pattern);
for (int i = 0; i < source.Length; i++) {
if (regex.IsMatch(source[i])) {
Match match = regex.Match(source[i]);
if (!match.Value.Contains("No Change")) {
dest[i] = Regex.Replace(dest[i], pattern, match.Value);
}
}
}
File.WriteAllLines(destPath, dest);
Kind regards,
wizend
No comments:
Post a Comment