parse the timestamp from a file using c#

Class library usage, coding and language questions.
Posts: 1
Joined: Mon Oct 26, 2015 9:18 pm

parse the timestamp from a file using c#

Post by prashanthkrp2 » Mon Oct 26, 2015 9:36 pm

as a part of my project i need to parse the timestamp from a file to determine the start date and time in my script that need to stat with that date and time. for this do i have to use linq to xml method for parsing the timestamp.?

osversion="Windows 7 Service Pack 1 64bit"
timestamp="8/12/2015 9:47:05 AM"

the last line shows the timestamp that needs to be parsed in to my script using c# coding.

User avatar
Ranorex Guru
Ranorex Guru
Posts: 4424
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: parse the timestamp from a file using c#

Post by odklizec » Tue Oct 27, 2015 11:54 am


Using XML reader is probably the cleanest way? Something like this should do the trick...

Code: Select all

	using System.IO;
	using System.Xml;

	public string ReadFromXML()
		XmlDocument doc = new XmlDocument();
		string attrVal = doc.SelectSingleNode(".//activity").Attributes["timestamp"].Value;
		return attrVal;
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration