Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading XML File (iterative) and then performing an action

Status
Not open for further replies.

tahirk

Programmer
Oct 24, 2005
47
GB
Hi,

I have written a simple application that queries a local or remote computer's services and then outputs the results to the screen and a simple text log file.

The app currently takes two arguments, the machine and the service name, it then passes the arguments into two variables and uses this to query the service status. I am using the System.ServiceProcess namespace and the System.Diagnostics namespace.

What I want to do now is to turn the little app into a scheduled job and to do this I want it to work through a list of machines, query their services, and then write this information to a log file.

I have decided XML is the best tool for this as it means I can simply export an Oracle table to an XML file and then get the C# app to read the XML file elements for the machine name, the services and the perform the service query action.

As I am still learning the ropes with C# I am not too familiar with the XML namespace and I am having trouble trying to construct a class that will do the following:

1. Open an external XML file (I am thinking of using the XMLDocument option for this)
2. Move to the first Element and read the hostname
3. FOR each SERVICE in MACHINE
3.1 Query Service Status and log result

I have tried the various Microsoft examples however I feel due to my current lack of experience with C# and XML I am struggling to find a suitable solution.

Many thanks in advance,

FZ
 
Thanks JurkMonkey, that tutorial gave me allot of ideas and I am able to go ahead and code up something useful now ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top