var criteria = da.getTrialCriteria(trialID);
try
{
var xdoc = new XDocument(new XDeclaration("1.0", "utf-8", "yes"));
var xroot = new XElement("trials");
xdoc.Add(xroot);
while (criteria.Read())
{
#region switch statement
switch ((string)criteria["type"])
{
case "trial":
{
var xElement = new XElement("trial",
new XAttribute("ID", criteria[1]),
new XElement("name", criteria[2])
);
xroot.Add(xElement);
break;
}
case "diseases":
{
var xsubroot = new XElement("diseases");
xdoc.Add(xsubroot);
var xElement = new XElement("disease",
new XAttribute("ID", criteria[1]),
new XElement("name", criteria[2])
);
xroot.Add(xElement);
break;
}
case "ethnicity":
{
var xsubroot = new XElement("ethnicities");
xdoc.Add(xsubroot);
var xElement = new XElement("ethnicity",
new XAttribute("ID", criteria[1]),
new XElement("name", criteria[2])
);
xroot.Add(xElement);
break;
}
case "bloodGroup":
{
var xsubroot = new XElement("bloodGroups");
xdoc.Add(xsubroot);
var xElement = new XElement("bloodGroup",
new XAttribute("ID", criteria[1]),
new XElement("name", criteria[2])
);
xroot.Add(xElement);
break;
}
}
#endregion
}
xdoc.Save(@"c:/WrongFormat.xml");
}
|