CSharp examples for System.Xml:XML Node
Get Date Time from XmlNode
using System.Globalization; using System.Security.Cryptography; using System.ComponentModel; using System.Runtime.InteropServices; using System.Collections; using System.Xml.XPath; using System.Text; using System.Xml; using System.IO;//from ww w.j a v a 2 s . com using System; public class Main{ /// <summary> /// /// </summary> /// <param name="Node"></param> /// <param name="NodeName"></param> /// <returns></returns> public static DateTime GetDateTime(XmlNode Node, string NodeName) { DateTime result = new DateTime(0); string s = GetString(Node, NodeName).Trim(); if (s.Length > 0) { try { result = ParseEBayTime(s); } catch (ArgumentNullException) { } catch (FormatException) { } } return result; } /// <summary> /// /// </summary> /// <param name="Navigator"></param> /// <param name="XPath"></param> /// <returns></returns> public static DateTime GetDateTime(XPathNavigator Navigator, XPathExpression XPath) { DateTime result = new DateTime(0); string s = GetString(Navigator, XPath).Trim(); if (s.Length > 0) { try { result = ParseEBayTime(s); } catch (ArgumentNullException) { } catch (FormatException) { } } return result; } /// <summary> /// /// </summary> /// <param name="Navigator"></param> /// <param name="NodeName"></param> /// <returns></returns> public static DateTime GetDateTime(XPathNavigator Navigator, string NodeName) { DateTime result = new DateTime(0); string s = GetString(Navigator, NodeName).Trim(); if (s.Length > 0) { try { result = ParseEBayTime(s); } catch (ArgumentNullException) { } catch (FormatException) { } } return result; } }