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>
hoyaabanksAsked:
Who is Participating?
 
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
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.