473,799 Members | 3,422 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C#-APP: search and retrieve a Regex from an xml file

1 New Member
The test tool I use produces xml files that I am parsing and inserting into a mysql database. I then have a set of php pages that report on the test results.

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
  1. Regex VersionRegex = new Regex(".*[1-9][.][0-9][.][0-9][.][0-9].*");
That should find a version string like 8.0.1.123. This is relatively quick, but then I need to retrieve the version number and I do that with this:
Expand|Select|Wrap|Line Numbers
  1.             foreach (string Word in ResContentsArray) {
  2.               if (VersionRegex.IsMatch(Word)) {
  3.                 VersionString = Word.Split('<')[0];
  4.                 break;
  5.               }
  6.             }
That code appears to be what is extremely slow. I crate ResContentsArra y like this:
Expand|Select|Wrap|Line Numbers
  1.             // put the xml file into my text reader
  2.             FileInfo ResFileInfo = new FileInfo(this.ResultFile);
  3.             StreamReader ResStream = ResFileInfo.OpenText();
  4.             string ResContents = ResStream.ReadToEnd();
  5.             string[] ResContentsArray = ResContents.Split(' ');
  6.             ResStream.Close();
  7.             ResStream.Dispose();
So, how can I regex search for the version string and return it relatively quickly.

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
  1. XmlReader XmlIn = new XmlTextReader("c:\\file.xml");
and then I XmlIn.Read() till I get to nodes I am looking for. I then build the SQL insert query and execute it. Is there a faster way?
Nov 9 '07 #1
0 1194

Sign in to post your reply or Sign up for a free account.

Similar topics

4
3034
by: jandt | last post by:
I know that you can retrieve data from a form using Request.Form("name"), but how do you retrieve a file?
3
1785
by: Mal Reeve | last post by:
Hello, I am looking for an easy way to retrieve a file from a given website.. I am building an app that will retrieve a .csv file then TRANSFER text it into a table for further processing.. Any pointers would be greatly appreciated. TIA
2
2082
by: Gregory Hassett | last post by:
Hello, I am using the BITS downloader to retrieve a file as part of a self-updating application. The file is called xyz.dll -- and when BITS tries to get it from its location (where it's hosted on a MS IIS Server), IIS sees the request for http://myserver/xyz.dll and attempts to execute the DLL (ala CGI) instead of returning the .DLL file to the requestor.
0
263
by: bob biris | last post by:
We're trying to interface with a third party application. To retrieve a file stored by them, we need to post some input parameters to an https server and the output will be a file. We would like to do this in the code behind page, for example using a web client, post to the server, get the file and copy it locally to be used later in the code. Can it be done?
6
1355
by: joltman | last post by:
I am trying to find out how to search for a file. I am making a switchboard program with buttons pointing to programs, but I want to make it so that if the program a button points to ever moves, it will automatically search the local hard drives for it. Thanx -joltman
1
4399
by: Andrew | last post by:
Hi, im trying to create a small function which can create a binary tree from the entries in a text file and after that we can perform all the usual operations like search, insert and delete etc. Now i have entries something like this IPaddress Phone No 192.168.2.1 2223447689 192.168.2.2 3334449898 192.168.2.3 5667869089
3
1517
by: mse07 | last post by:
hi all i search about statement in text file by this code : LineFlag = LineFlag + 1 Line Input #1, strLine If LineFlag = 15 Then If InStr(1, strLine, " Transfer completed successfully.") <> 0 Then MsgBox "successful"
0
1006
by: shivavodnala | last post by:
hi , i have to retrieve a video file retrieve video file from sql server2000 database and it has to play on media player at browser,please send code
7
1681
by: Vipul03 | last post by:
I want to search a regex in perl without replacing it and without going line by line to search it Any help will be apriciable Thanks in advance
7
2506
by: xraive | last post by:
Currently I only get the file path. Is there way to retrieve the file name or do I have to just use the split function. Dim fDialog As Office.FileDialog Dim varFile As Variant 'Clear listbox contents. 'Me.FileList.RowSource = "" 'Set up the File Dialog.
0
9688
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9544
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9077
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7570
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5589
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4145
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.