I wrote a C# console application that parses the xml file and performs the db insert. I am using MySQLDriverCS as the interface to mysql.
The problem I am having is that it is a little slow. One of the bottlenecks I have is looking for the version string in the xml file. I created a Regex to look for the version string:
Expand|Select|Wrap|Line Numbers
- Regex VersionRegex = new Regex(".*[1-9][.][0-9][.][0-9][.][0-9].*");
Expand|Select|Wrap|Line Numbers
- foreach (string Word in ResContentsArray) {
- if (VersionRegex.IsMatch(Word)) {
- VersionString = Word.Split('<')[0];
- break;
- }
- }
Expand|Select|Wrap|Line Numbers
- // put the xml file into my text reader
- FileInfo ResFileInfo = new FileInfo(this.ResultFile);
- StreamReader ResStream = ResFileInfo.OpenText();
- string ResContents = ResStream.ReadToEnd();
- string[] ResContentsArray = ResContents.Split(' ');
- ResStream.Close();
- ResStream.Dispose();
Currently the XML files are around 750-850k in size but are likely to grow with time.
Getting the version string is all part of setting up the result_set which contains a product version, platform, architecture, server, date, etc. Once I have a result_set id, I can start inserting the body of the tests and associate them to that result_set.
I would like to find a faster way to import the xml result data into my mysql database. I am currently using
Expand|Select|Wrap|Line Numbers
- XmlReader XmlIn = new XmlTextReader("c:\\file.xml");