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

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

parse the timestamp from a rxlog.data 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 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.

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

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

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

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;
	}      
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