Date Format In XML in converting excel file in a folder
-
How we get XML tag value in MM/DD/YYYY format in .net with c# ??
private string getXmlTagDate(XmlElement xEle, string name) { XmlNodeList xList; string text; xList = xEle.GetElementsByTagName(name); if (xList.Count > 0) { text = xList[0].InnerText.ToString(); text = Convert.ToDateTime(text).ToShortDateString(); } else { text = "00/00/0000"; } return text; }
this function work properly for text value and we get this in date format<?xml version="1.0" standalone="yes"?> <NewDataSet> <PinType_TABLE> <pinname>HALF UNIT</pinname> <fullvalue>12000</fullvalue> <percent_value>50</percent_value> <pin_type>P</pin_type> <pin_price>6000</pin_price> <ind_active>1</ind_active> <CreateOn>2009-02-01T00:00:00+05:30</CreateOn> </PinType_TABLE> <PinType_TABLE> <pinname>Full</pinname> <fullvalue>12000</fullvalue> <percent_value>100</percent_value> <pin_type>P</pin_type> <pin_price>12000</pin_price> <ind_active>1</ind_active> <CreateOn>2009-02-03T00:00:00+05:30</CreateOn> </PinType_TABLE> <PinType_TABLE> <pinname>fourth unit</pinname> <fullvalue>12000</fullvalue> <percent_value>25</percent_value> <pin_type>P</pin_type> <pin_price>3000</pin_price> <ind_active>1</ind_active> <CreateOn>2009-05-21T00:00:00+05:30</CreateOn> </PinType_TABLE> <PinType_TABLE> <pinname>s.s</pinname> <fullvalue>12000</fullvalue> <percent_value>0</percent_value> <pin_type>P</pin_type> <pin_price>0</pin_price> <ind_active>1</ind_active> <CreateOn>2009-07-16T00:00:00+05:30</CreateOn> </PinType_TABLE> </NewDataSet>
-
How we get XML tag value in MM/DD/YYYY format in .net with c# ??
private string getXmlTagDate(XmlElement xEle, string name) { XmlNodeList xList; string text; xList = xEle.GetElementsByTagName(name); if (xList.Count > 0) { text = xList[0].InnerText.ToString(); text = Convert.ToDateTime(text).ToShortDateString(); } else { text = "00/00/0000"; } return text; }
this function work properly for text value and we get this in date format<?xml version="1.0" standalone="yes"?> <NewDataSet> <PinType_TABLE> <pinname>HALF UNIT</pinname> <fullvalue>12000</fullvalue> <percent_value>50</percent_value> <pin_type>P</pin_type> <pin_price>6000</pin_price> <ind_active>1</ind_active> <CreateOn>2009-02-01T00:00:00+05:30</CreateOn> </PinType_TABLE> <PinType_TABLE> <pinname>Full</pinname> <fullvalue>12000</fullvalue> <percent_value>100</percent_value> <pin_type>P</pin_type> <pin_price>12000</pin_price> <ind_active>1</ind_active> <CreateOn>2009-02-03T00:00:00+05:30</CreateOn> </PinType_TABLE> <PinType_TABLE> <pinname>fourth unit</pinname> <fullvalue>12000</fullvalue> <percent_value>25</percent_value> <pin_type>P</pin_type> <pin_price>3000</pin_price> <ind_active>1</ind_active> <CreateOn>2009-05-21T00:00:00+05:30</CreateOn> </PinType_TABLE> <PinType_TABLE> <pinname>s.s</pinname> <fullvalue>12000</fullvalue> <percent_value>0</percent_value> <pin_type>P</pin_type> <pin_price>0</pin_price> <ind_active>1</ind_active> <CreateOn>2009-07-16T00:00:00+05:30</CreateOn> </PinType_TABLE> </NewDataSet>
Just i would like to clerify you query that are facing problem with the date formate while you are converting XML file into excel file ?
Parwej Ahamad ahamad.parwej@gmail.com
-
How we get XML tag value in MM/DD/YYYY format in .net with c# ??
private string getXmlTagDate(XmlElement xEle, string name) { XmlNodeList xList; string text; xList = xEle.GetElementsByTagName(name); if (xList.Count > 0) { text = xList[0].InnerText.ToString(); text = Convert.ToDateTime(text).ToShortDateString(); } else { text = "00/00/0000"; } return text; }
this function work properly for text value and we get this in date format<?xml version="1.0" standalone="yes"?> <NewDataSet> <PinType_TABLE> <pinname>HALF UNIT</pinname> <fullvalue>12000</fullvalue> <percent_value>50</percent_value> <pin_type>P</pin_type> <pin_price>6000</pin_price> <ind_active>1</ind_active> <CreateOn>2009-02-01T00:00:00+05:30</CreateOn> </PinType_TABLE> <PinType_TABLE> <pinname>Full</pinname> <fullvalue>12000</fullvalue> <percent_value>100</percent_value> <pin_type>P</pin_type> <pin_price>12000</pin_price> <ind_active>1</ind_active> <CreateOn>2009-02-03T00:00:00+05:30</CreateOn> </PinType_TABLE> <PinType_TABLE> <pinname>fourth unit</pinname> <fullvalue>12000</fullvalue> <percent_value>25</percent_value> <pin_type>P</pin_type> <pin_price>3000</pin_price> <ind_active>1</ind_active> <CreateOn>2009-05-21T00:00:00+05:30</CreateOn> </PinType_TABLE> <PinType_TABLE> <pinname>s.s</pinname> <fullvalue>12000</fullvalue> <percent_value>0</percent_value> <pin_type>P</pin_type> <pin_price>0</pin_price> <ind_active>1</ind_active> <CreateOn>2009-07-16T00:00:00+05:30</CreateOn> </PinType_TABLE> </NewDataSet>
rummer wrote: text = Convert.ToDateTime(text).ToShortDateString(); text= Convert.ToDateTime(text).Tostring("MM/dd/yyyy");
Regards Keyur Satyadev