Processing XML Files

I am developing a C# application that monitors a directory on a server for XML files.  These XML files are written to this directory through a separate application.  What my application needs to do is grab the XML file, parse it, insert the data into a database, and remove the file to separate location.  I am using the file system watcher class for listening to the files.  My question is what is the best way to read these XML files?  Should I read them into a dataset or is there another efficient way of doing it?   I am a novice .NET developer so any help will be appreciated.

Who is Participating?
ptmcompConnect With a Mentor Commented:
Well, it depends how they should be stored in the database. If they are stored as text then it would be enough to just load them as text. Validating them whould be good to avoid garbage being written to the database... That can be done using an XmlValidatingReader and listening to the events.
XmlDocument would be easier and straight forward but it has more overhead. If there are few small files this is not relevant but if they are big you the way described before might be better...
Bob LearnedCommented:
Is the XML file structure simple?  Are they small, medium or large files?  If so, then using the DataSet.ReadXML is a very straight forward approach.

All Courses

From novice to tech pro — start learning today.