• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 365
  • Last Modified:

Creating and Modifying XML Documents

I am creating custom error logging using an XML document that looks like the example below.  What is the best way to create logic to edit this file, so that when a new error occures I can quickley and effortlsly write it to an error log file in some reusable way.

I am using ASP.NET and C#.

Example:
=======================
<?xml version="1.0" encoding="utf-8" ?>
<ErrorLog Date="03/04/07">
  <Error Time="04:20:00">
    <Message Exception="System.InvalidOperationException">
         Data keys must be specified on GridView 'gvCategories' before the selected data keys can be retrieved.  Use the DataKeyNames property to specify data keys.
</Message>
    <User>john.smith@js.com</User>
    <StackTrace>

[InvalidOperationException: Data keys must be specified on GridView 'gvCategories' before the selected data keys can be retrieved.  Use the DataKeyNames property to specify data keys.]
   System.Web.UI.WebControls.GridView.get_SelectedDataKey() +1500582
   System.Web.UI.WebControls.GridView.get_SelectedValue() +12

[TargetInvocationException: Property accessor 'SelectedValue' on object 'System.Web.UI.WebControls.GridView' threw the following exception:'Data keys must be specified on GridView 'gvCategories' before the selected data keys can be retrieved.  Use the DataKeyNames property to specify data keys.']
   System.ComponentModel.ReflectPropertyDescriptor.GetValue(Object component) +370
   System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName) +77
   System.Web.UI.DataBinder.Eval(Object container, String[] expressionParts) +79
   System.Web.UI.DataBinder.Eval(Object container, String expression) +108
   System.Web.UI.WebControls.ControlParameter.Evaluate(HttpContext context, Control control) +310
   System.Web.UI.WebControls.Parameter.UpdateValue(HttpContext context, Control control) +46
   System.Web.UI.WebControls.ParameterCollection.UpdateValues(HttpContext context, Control control) +103
   System.Web.UI.WebControls.ObjectDataSource.LoadCompleteEventHandler(Object sender, EventArgs e) +40
   System.EventHandler.Invoke(Object sender, EventArgs e) +0
   System.Web.UI.Page.OnLoadComplete(EventArgs e) +2058120
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1209
</StackTrace>
  </Error>  
</ErrorLog>
0
hoyaabanks
Asked:
hoyaabanks
  • 3
  • 2
1 Solution
 
davecorunCommented:
I use the Enterprise Library extensively, and there is an Exception Handling Application Block which represents most of the best practices for Exception Handling.

http://msdn2.microsoft.com/en-us/library/aa480461.aspx

Definitely worth a look.  You can specify policies, which it seems is exactly what you're describing.
0
 
hoyaabanksAuthor Commented:
The more important part of this question is best practices for creating and manipulation XML documents.  This XML exception handling system is a requirement for the project I am on, because that is how we drive the data to flash.
0
 
davecorunCommented:
If you're asking how to properly read / write the XML file, try the XmlDocument or XmlStreamReader class.  Those are your best bets.
0
Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
hoyaabanksAuthor Commented:
Do you have a good example of tutorail, or a couple of lines of code that show you how to access and write independent nodes using those objects?
0
 
Computer101Commented:
Forced accept.

Computer101
EE Admin
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now