//path of your RDF file i.e. txt file used delimeter |
String filePath = Path.Combine(HostingEnvironment.ApplicationPhysicalPath, @"RdfFile/RDF.txt");
IEnumerable<String> source = File.ReadLines(filePath);
XElement scans = new XElement("Test",
from str in source
let fields = str.Split('|')
select new XElement("Product",
new XAttribute("Action", FileName),
new XAttribute("EnsureDefaultVariant", "1"),
new XAttribute("ID", fields[0]),
new XElement("Summary", fields[2]),
new XElement("ImageFilenameOverride", fields[1])
)
);
//path in which xml file you want to save result.
String filePath_Xml = Path.Combine(HostingEnvironment.ApplicationPhysicalPath,
@"XMLFile/RDF__Scans_Add_XMLFile.xml");
scans.Save(filePath_Xml);