Page 1 of 1

parse the timestamp from a rxlog.data file using c#

Posted: Mon Oct 26, 2015 9:36 pm
by prashanthkrp2
as a part of my project i need to parse the timestamp from a rxlog.data 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.?

<report>
<activity
user="chanderu"
host="CA630029"
rxversion="5.3.2.23378"
osversion="Windows 7 Service Pack 1 64bit"
runtimeversion="4.0.30319.34209"
procarch="32bit"
language="en-US"
screenresolution="1600x1200"
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.

Re: parse the timestamp from a rxlog.data file using c#

Posted: Tue Oct 27, 2015 11:54 am
by odklizec
Hi,

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();
		doc.Load(@"C:\pathtoreport\report.rxlog.data");
		string attrVal = doc.SelectSingleNode(".//activity").Attributes["timestamp"].Value;
		return attrVal;
	}