I have an xml config file and with all the processes I’m including, it makes my xml file over 1000 lines long. My team is complaining that the size of the file makes it tough to update. Does anyone have any ideas on how to shorten/simplify the xml document?
This is what the xml format looks like:
<?xml version="1.0" encoding="UTF-8"?>
<BuildVerficationRoot>
<Configuration>
<Value Name="emailFrom">[email protected]</Value>
<Value Name="admin_list">[email protected]</Value>
<Value Name="distribution_list">[email protected]</Value>
<Value Name="SmtpMailClient">info.co.net</Value>
<Value Name="verboseLogFileName">VerifyBuildVerbose.txt</Value>
<Value Name="statsLogProcessVerFileName">Stats.txt</Value>
<Value Name="project">proj</Value>
<Value Name="version">1.0</Value>
<Value Name="publishHeader">PublishDestination</Value>
</Configuration>
<BuildVerification>
<codeFreezeTime>19:00</codeFreezeTime>
<build>
<BuildMachine>mach-1</BuildMachine>
<Process>
<ProcessName>Version</ProcessName>
<startTimeHeader>StartTime</startTimeHeader>
<endTimeHeader>EndTime</endTimeHeader>
<failureColumns>ErrorDescription</failureColumns>
<Conditions>
<Condition
name='VersionFile' value="viewdevRetailfilename.cs">
</Condition>
</Conditions>
<SuccessCriteria>
<field>Status</field>
<comparison>equal</comparison>
<value>Success</value>
</SuccessCriteria>
</Process>
<!--there are several build machines and each build machine has several processes under it, so this is what is many many lines -->
</build>
</BuildVerification>
</BuildVerficationRoot>
The way my program works, is that it reads the xml file using LINQ, and reads log files into a dataTable, and I iterate over the Lists storing the LINQ, and compare with data in the log files to determine if the builds were successful.
This is the associated LINQ I use to retrieve the xml data:
var results1 =
xmlDoc2.Descendants("build")
.SelectMany(b => b.Descendants("Process")
.Select(p => new ProcessValidationInfo
{
codeFreezeTime = b.Parent.Element("codeFreezeTime").Value,
buildMach = b.Element("BuildMachine").Value,
p1 = p.Element("ProcessName").Value,
startTimeHeader = p.Element("startTimeHeader").Value,
endTimeHeader = p.Element("endTimeHeader").Value,
conditionList = p.Descendants("Condition")
.Select(c => new Condition
{
cName = c.Attribute("name")?.Value,
cValue = c.Attribute("value")?.Value,
cValueAlternate = c.Attribute("alternateValue")?.Value
})
.ToList(),
successCriteriaList = p.Descendants("SuccessCriteria")
.Select(sc => new SuccessCriteria
{
f1 = sc.Element("field")?.Value,
c1 = sc.Element("comparison")?.Value,
v1 = sc.Element("value")?.Value,
alt_v1 = sc.Element("alternateValue")?.Value
})
.ToList()
})).ToList();
//int i_tmpResults = 0;
foreach (var currentItem in results1)
{
//Console.WriteLine("here Media not good");
xml_results += ParseLogFile1(currentItem);
}
Looking for simplified xml and associated ideas for the LINQ that goes with the simplified xml.
For more info on this project, like classes used to store the info that is referred to in the LINQ, see classes for LINQ.
The area of xml that needs shortening is in the tag, which is very long. It works perfectly, just the team thinks the xml is too long so it’s unwieldy.
I saw xml minifier, but it just appears to remove line breaks so it’s all horribly formatted.
1