Tech Off Thread

6 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Reading data from an XML file

Back to Forum: Tech Off
  • User profile image

    Please bear with me, this is pretty low tech.
    As I try to dust of my meager programming skills of long ago, I try to find what is the best way to read data from an XML file and put it into either a database or spreadsheet.
    Here is an example:

    <?xml version="1.0" encoding="utf-8"?><session sessioncode="322546571"> 
              <gametype>Omaha PL 0.10/0.20</gametype> 
              <tablename>Two Rocks</tablename> 
              <startdate>2007-04-29 13:26:41</startdate> 

         <game gamecode="539425608">
    The files are longer but this is all data I want.
    I'm thinking along the lines of reading it with some scritping language, making a CSV file and importing it into a database or spreadsheet.
    Any recommendations?

  • User profile image

    If it is well-formed XML, you can read it directly into a DataSet.


  • User profile image

    As with most solutions, there are multiple ways to do it.

    If you can't pull it directly into a dataset as JohnAskew suggested then you can definitely use XPath querying of the XML once it is loaded into a XmlDocument object.

    If you need to work with a large XML file or performance is absolutely a must you can use XPathNavigator as it is more performant than XPath queries, but the queries are quite simple.

    You could then iterate and produce your CSV or feed into a database.

  • User profile image

    Thanks, I have my work cut out for me :O
    Which was exactly what I was looking for. Reading XML files and processing and analyzing the data is mostly an excuse to get myself into programming. This will likely take me weeks to get something decent running. I can buy a program for $55 that does it automatically for many sites, collects much more data, goes into much more detail and so forth but were is the fun in that? Big Smile

  • User profile image

    oh my god, i'm such an idiot, i wrote my own xml parser when i needed one & have been showing the code to potential employers :o i feel like such a (I need to watch my language)!

  • User profile image

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.