ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Read XML file and check Date is Null or Not using C# and VB.Net in ASP.Net <p>I will get back soon.</p>https://www.aspforums.net:443/Threads/383523/Read-XML-file-and-check-Date-is-Null-or-Not-using-C-and-VBNet-in-ASPNet/https://www.aspforums.net:443/Threads/383523/Read-XML-file-and-check-Date-is-Null-or-Not-using-C-and-VBNet-in-ASPNet/Sun, 09 Dec 2018 23:09:02 GMTRead XML file and check Date is Null or Not using C# and VB.Net in ASP.Net <p>Hey <a class="username" rel="SonaliB">SonaliB</a>,</p> <p>Please refer below sample.</p> <p><span style="text-decoration: underline;"><strong>Namespaces</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">using System.Xml; using System.Globalization; using System.Text.RegularExpressions;</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Imports System.Xml Imports System.Globalization</pre> <p><span style="text-decoration: underline;"><strong>Code</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { Regex regex = new Regex(@&#34;(((0|1)[0-9]|2[0-9]|3[0-1])\/(0[1-9]|1[0-2])\/((19|20)\d\d))$&#34;); string[] formats = { &#34;yyyy-MM-dd&#34; }; string FilePath = Server.MapPath(&#34;~/XMLFile.xml&#34;); XmlDocument doc = new XmlDocument(); doc.Load(FilePath); XmlNodeList nodeList = doc.SelectNodes(&#34;/Record/record/AirDate&#34;); foreach (XmlNode node in nodeList) { bool isValid = regex.IsMatch(node.InnerText); if (!isValid) { string datetime = node.InnerText; if (string.IsNullOrEmpty(datetime)) { ScriptManager.RegisterStartupScript(this, this.GetType(), &#34;CropImage&#34;, &#34;alert(&#39;xml file have no date.&#39;);&#34;, true); } else { DateTime yyydate = Convert.ToDateTime(datetime); string result = yyydate.ToString(&#34;dd/MM/yyyy&#34;, CultureInfo.InvariantCulture); } } } } }</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load If Not Me.IsPostBack Then Dim regex As Regex = New Regex(&#34;(((0|1)[0-9]|2[0-9]|3[0-1])\/(0[1-9]|1[0-2])\/((19|20)\d\d))$&#34;) Dim formats As String() = {&#34;yyyy-MM-dd&#34;} Dim FilePath As String = Server.MapPath(&#34;~/XMLFile.xml&#34;) Dim doc As XmlDocument = New XmlDocument() doc.Load(FilePath) Dim nodeList As XmlNodeList = doc.SelectNodes(&#34;/Record/record/AirDate&#34;) For Each node As XmlNode In nodeList Dim isValid As Boolean = regex.IsMatch(node.InnerText) If Not isValid Then Dim datetime As String = node.InnerText If String.IsNullOrEmpty(datetime) Then ScriptManager.RegisterStartupScript(Me, Me.[GetType](), &#34;CropImage&#34;, &#34;alert(&#39;xml file have no date.&#39;);&#34;, True) Else Dim yyydate As DateTime = Convert.ToDateTime(datetime) Dim result As String = yyydate.ToString(&#34;dd/MM/yyyy&#34;, CultureInfo.InvariantCulture) End If End If Next End If End Sub</pre>https://www.aspforums.net:443/Threads/383523/Read-XML-file-and-check-Date-is-Null-or-Not-using-C-and-VBNet-in-ASPNet/https://www.aspforums.net:443/Threads/383523/Read-XML-file-and-check-Date-is-Null-or-Not-using-C-and-VBNet-in-ASPNet/Mon, 10 Dec 2018 01:01:29 GMT