i have 1 xml file , want generate custom list xml using linq. here code. not getting records.here code.
public class templatesettings { public string decimalseparator { get; set; } public string thousandseparator { get; set; } public string dateseparator { get; set; } public string timeseparator { get; set; } } xml here
<templatesetting> <decimalseparator>1</decimalseparator> <thousandseparator>2</thousandseparator> <dateseparator>3</dateseparator> <timeseparator>4</timeseparator> <dateformat>dd/mm/yyyy</dateformat> <valuedelimiter>tr</valuedelimiter> <quotecharacter>r</quotecharacter> <isheader>false</isheader> </templatesetting> and code object xml
var = (from x in objtemplatemastereal.templatsettingsxml.elements("templatesetting") select new templatesettings() { dateformat = (string)x.element("dateformat"), decimalseparator = (string)x.element("decimalseparator"), thousandseparator = (string)x.element("thousandseparator"), dateseparator = (string)x.element("dateseparator"), timeseparator = (string)x.element("timeseparator"), quotecharacter = (string)x.element("quotecharacter"), valuedelimiter = (string)x.element("valuedelimiter"), isheaderline = (bool)x.element("isheader") }).tolist<templatesettings>(); can 1 suggest me wrong here ?
if goal deserialize xml object can use this:
class program { static void main(string[] args) { using (streamreader reader = new streamreader("sample.xml")) { var serializer = new xmlserializer(typeof(templatesetting)); var templatesetting = (templatesetting)serializer.deserialize(reader); } } } [xmlroot] public class templatesetting { public string decimalseparator { get; set; } public string thousandseparator { get; set; } public string dateseparator { get; set; } public string timeseparator { get; set; } }
Comments
Post a Comment