I have an XML file which has lots of values as below, placing just sample
Expand|Select|Wrap|Line Numbers
- <Entries>
- <Application1>
- <key>12</key>
- <alerts>res12 ### test</alerts>
- </Application1>
- <Application2>
- <key>13</key>
- <alerts>res 13 ### test</alerts>
- </Application2>
- </Entries>
Event viewer consists of key id and the description (alerts)
I have captured the event viewer part. But I have to split "Application1" in one alert and "Application2" in an another alert.
My program is straight forward
Expand|Select|Wrap|Line Numbers
- XmlTextReader reader = new XmlTextReader(@"C:\Examples\tivolialert\Tivoli.xml");
- string skey = string.Empty;
- string salert = string.Empty;
- int intkey = 0;
- reader.Read();
- while (reader.Read())
- {
- if (reader.Name == "key")
- {
- skey = reader.ReadString();
- }
- if (reader.Name == "Alert")
- {
- salert = reader.ReadString();
- bool result = Int32.TryParse(skey, out intkey);
- EventLog.WriteEntry("Some source", salert, EventLogEntryType.Error, intkey);
- }
- }
- Console.ReadLine();
- }
I have only one hurdle, I need to capture Application wise, i.e. if its Application1 then the source ("Some source") will be different, if its Application2 the source will be different.
How do I figure it out?