Parse log file containing Xml

I have some log files that contain text and Xml ie:

--------------Begin-----------------------
Some data here
Some more data here
InputXML = <?xml version="1.0" encoding="UTF-8"?>
<Root>
	<Element>Data</Element>
	<AnotherElement attribute="hello">Data</AnotherElement>
</Root>
OutputXML = <?xml version="1.0" encoding="UTF-8"?>
<Root>
	<Element>Data</Element>
	<AnotherElement attribute="hello">Data</AnotherElement>
</Root>
More Data
--------------End-----------------------
--------------Begin-----------------------
....
--------------Begin-----------------------

I want to parse this file and insert the Xml plus bits of the other
data into a database.  I have tried to use a streamreader looking for
the Xml declaration then passing the stream into an XmlTextReader to
grab the Xml bits of the log file but without much success has anybody
managed to do anything similar to this and if so what classes did you
use?

Thanks

Lee
0
11/5/2009 4:19:56 PM
dotnet.xml 7266 articles. 0 followers. Follow

2 Replies
1962 Views

Similar Articles

[PageSpeed] 30

Lee wrote:
> I have some log files that contain text and Xml ie:
> 
> --------------Begin-----------------------
> Some data here
> Some more data here
> InputXML = <?xml version="1.0" encoding="UTF-8"?>
> <Root>
> 	<Element>Data</Element>
> 	<AnotherElement attribute="hello">Data</AnotherElement>
> </Root>
> OutputXML = <?xml version="1.0" encoding="UTF-8"?>
> <Root>
> 	<Element>Data</Element>
> 	<AnotherElement attribute="hello">Data</AnotherElement>
> </Root>
> More Data
> --------------End-----------------------
> --------------Begin-----------------------
> ...
> --------------Begin-----------------------
> 
> I want to parse this file and insert the Xml plus bits of the other
> data into a database.  I have tried to use a streamreader looking for
> the Xml declaration then passing the stream into an XmlTextReader to
> grab the Xml bits of the log file but without much success has anybody
> managed to do anything similar to this and if so what classes did you
> use?

Well it looks as if you can read in line by line until you have a line 
starting with "InputXML = ", then you can read and buffer contents until 
you fine a line starting with "OutputXML = ", that way you should have 
the first XML contents and the start of the second XML contents. You 
have not indicated whether "More Data" has some pattern to allow you to 
find the end of the second XML.


-- 

	Martin Honnen --- MVP XML
	http://msmvps.com/blogs/martin_honnen/
0
mahotrash (1777)
11/5/2009 5:57:23 PM
"Lee" <lee.keable@gmail.com> wrote in message news:f15a56db-dcaf-48a7-bafd-ba4fcbd029d6@r24g2000yqd.googlegroups.com...
>I have some log files that contain text and Xml ie:

....
> I want to parse this file and insert the Xml plus bits of the other
> data into a database.


Looks like a job for  LogParser?

Where's "Flowering Weeds" when we need him/her?  ; )


--- 


0
robald (26)
11/6/2009 3:48:31 AM
Reply:

Similar Artilces:

.qfx file in excel
my bank for some reason will only allow me to download my statement in a qfx file (quicken) but i dont have any quicken programs i use excel to manage my finances how can i open this file up??? If the bank does not have .text (.txt) or comma separated variables (.csv), which would probably be listed as spreadsheet format, then I would complain to the bank. Meanwhile you could copy and paste from your checking activity HTML pages. --- HTH, David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001] My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm Search Page: ...

.mdi Files
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel I have some .mdi files (generated at work with some lab software). They seem to open okay on my work PC. Is there any way that I can get Office 2008 and a MAC to recognize / open these? No, .mdi is a Windows-only format exclusive to the Microsoft Document Imaging program... Even other Windows apps can't read or create them. If you can get them into a Windows box open them in MDI & then Save As TIFF to get a format that can be opened by graphics apps or inserted into other documents as a picture. TIFF files are ...

Unable to start up my Excel files
One of my users have this odd issue with his Excel 2003. He's unable to start the files directly but instead he must start a blank excel sheet then open his files from there. Is there a solution to this issue? Please advise. Thanks! Dell 170L P4 800mghz 1gbram Windows XP Pro SP2 Office 2003 SP2 Could the problem be that he cannot open files by double-clicking on them from Windows Explorer, but must open Excel (which will launch a blank sheet) and then open them directly from there using File / Open... If so then tell him to try Tools / Options / General / untick 'Ignore Othe...

File password override
I'm trying to restore a backup file. Money is asking for a file password. I enter the password that is appropriate for the Passport account used to lock the file, but Money will not accept that. I wonder if this file has a seperate file password and if so, I have no memory of what it may have been. Is there some way to reset it? Is there some other way in to this file? Thanks Though I sympathize with your problem, I certainly hope there's no back door. If there is, I'm going back to paper records. I shudder to think that a hacker could conceivably get an older backup file an...

opening .dat Accounts Receivable file in Great Plains for DOS
Hi There: We are trying to retrieve some information from a posted accounts receivable report... We think its in a .dat file but have no way of opening... This anyone know if this is possible... Any help or suggestions would be greatly appreciated! Sincerely, Carmine Carmine, Can you be a little more specific? What version of GP, what report, what information? Victoria "Carmine" <Carmine@discussions.microsoft.com> wrote in message news:839CC67C-A4C7-4584-8119-C40F74960573@microsoft.com... Hi There: We are trying to retrieve some information from a posted accounts ...

csv-file problems with different regions
I have imported an American csv-file into a German Excel XP. The American $-values are separated by a "." while the German currency values are separated by a ",". So now my spreadsheet reads a value of $ 18.01 as 18. January. All values above 18.12 are ok. How can I avoid this problem? Or, can I change the values tediously one cell after the other? I have not found a way yet as even when I try to format a cell user defined it automatically changes to the format used in the German region. Thanks. Hans Temporarily change the regional settings on your computer to the same f...

File set up query.
Can i set up an excel file to open automatically on pc start up? The easiest is to use the Startup folder available in the Start Menu. To access it go to Start - Programs - Startup. You can delete or add tasks here according to your needs. They will start after Windows logon. When you start Excel, all the files that are located in the XLStart folder are automatically opened. Additionally, if you specified an alternative startup folder for Excel, every file in that folder is also automatically opened. To specify an alternative startup folder, in Microsoft Excel 2002 or Microsof...

Sorting file list by date/time...
Hello, does anybody have an idea how to program a sorting function given a directory with files, which should red to an array which is sorted by date and time, but contains only the filenames. Is there a MFC function or a shell function of the OS which could ease the job instead of doing it manually? Regards, Diana On Mon, 16 Apr 2007 16:39:50 +0200, "Diana Bulthaupt" <Diana.Bulthaupt(at)web.de> wrote: >does anybody have an idea how to program a sorting function given a >directory with files, which should red to an array which is sorted by date >an...

Can I access the previous version of a saved file?
I overwrote an excel file by mistake, using the save as command to an incorrect file. Is there any way to recover the previous file before I "saved as" over it? Hi! I'm using Excel 10 (XP)......WinXP....... If I have an existing file and open it, make some changes, then do a SAVE AS and give it a different name, the newly "saved as" file is a completely *NEW* file and the original is still in tact with the previous file name. Try looking for the previous file name. Biff "JCC" <JCC@discussions.microsoft.com> wrote in message news:9CAD1748-1D5C...

how to edit Adobe file
how to edit Adobe file Most certainly not in Word. pdf files, I'm assuming that is what you mean by 'Adobe files', are 'fixed' files. Their layout is frozen so they look the same on any machine and can not be edited. If you still want to edit such a pdf file, you will have to convert the file to something else, edit it, and then save the result back as a pdf. The best tool to do the conversion of pdf files to Word documents is probably Acrobat Professional. Unfortunately, that is a rather expensive product to use for a few simple conversions. There are ...

Replicating Formulas between excel files
Hi there, Does anyone know how I can replicate formulas (verbatim) between difference excel files? I've tried to cut and paste between the separate files, but to my dismay it makes a reference to the original file. Regards, Nickchups The best procedure depends on how many you're trying to copy. For one or two, you can select the *entire* formula in the formula bar, right click and choose "Copy", then hit <Enter>. Now you can navigate to wherever you wish, and Paste it as many times and/or places you want. For numerous formulas, *unformulate* them by replacing t...

KDC event log error 11
I have a client that has installed MS CRM 1.2 on SBS 2003 PE. It looks like a bad install. It appears they may have even installed it twice because there are 2 x ‘CompanyX CRM version 1.2’ websites in IIS (one installed over the top of companyweb), and their RRW doesn’t work. They didn’t set up a new user to run the CRM service - they installed as Administrator and CRM uses that. They are getting KDC error's in the event log (event ID 11) and have complained about authentication errors. There are several different SPN's listed in the event log as being duplicated. The errors look ...

move files and prompt user if file already exists in target filepath
I have the following code that moves files between folders. Unfortunately, already existing files get overwritten if the new filename is the same. Is there a way to prompt the user in case the file would already exist and to abort the copy kill operation? here's my code: Private Sub Command9_Click() Dim strNewName As String Dim strOldName As String Dim strtargetfilepath As String strtargetfilepath = DLookup("[Draft to Active]", "filepath") strOldName = Me.Filename strNewName = strtargetfilepath & "\" & Me.Name1 FileCopy strOldName, strNe...

Want to hack the recently used file list max entries
Version: 2004 Operating System: Mac OS X 10.4 (Tiger) Processor: Power PC Would anyone care to offer a hack method to get the recently used file list to show more than 9 entries? No use telling me it can't be changed. I am asking for the &quot;Yes&quot; people to answer. OK, yes... The first thing you need to do is contact Microsoft & ask them for the source code. Seriously, there is no user option other than the setting provided in Preferences. If you want to see a longer list use the 'Recent' page of Project Gallery from the file menu. On its Customize page ...

SMTP Server Failure / Not Logging
We are running the following: Windows Server 2003 SP2 (all latest hotfixes) Exchange 2003 SP2 routing our outbound messages through a smart host as we have for the past 2 years (including a server rebuild in the past year) in a single server environment for my organization. Recently our users started receiving notifications that their messages had been delayed. When viewing the queue it shows a massive amount of messages waiting in the queue to be delivered through the smart host. When looking at the SMTP logs - the last entry listed is 504+Need+to+Authenticate +First. I reviewed the setti...

Outlook 2007 cannot open .pst file
I just installed Outlook 2007, then moved older outlook pst files successfully into my new Outlook. However, I closed it and then restarted it. It claims that it cannot open the Outlook.pst file anymore. In trouble, need any and all input as to how to fix it; other than completely reinstalling it. I will loose some new email that I downloaded. thank you, -- ravimk http://forums.slipstick.com Which method did you use to reconnect your older pst-files? "Moved it" is not a valid action nor does it describe exactly what you did. The proper way to reconnect...

Excel temp files in network dir
I have users that are accessing a network shares to their excel files. I often see files that are 8 characters long Ex(D8710B20) and without extensions, left over in their dir. I have read MS article 814068 and understand that these are created during the save function; however, i have ruled out permissions and antivirus as the cause. These files consume a lot of network space. Any guidance would greatly be appreciated. Delete them? "les" <les.becker@ifcosystems.com> wrote in message news:242501c37332$34e6b600$a601280a@phx.gbl... : I have users that are accessing...

XML file extensions
I have a machine with Excel 2003 Pro installed. Whenever I create an XML file in any directory on the hard drive (created from SQL Server Database via Visual Studio) the XML file is automatically converted to an Excel 4.0 Macro file. It is then no longer recognised as an XML file. It would appear that somehow XML files are associated with Excel automatically. Can I turn this off? TIA Rowan Ignore me, I coded the file extension as XLM by mistake - which of course is an Excel 4.0 Macro!!! "Rowan" wrote: > I have a machine with Excel 2003 Pro installed. Whenever I create...

Trying to open a Publisher file from School
At school kids have PUB 03 or 07 file they created and at we have Home PUB 00, we cannot open their file? Am I out of luck? Dad of 5 wrote: > At school kids have PUB 03 or 07 file they created and at we have Home PUB > 00, we cannot open their file? Am I out of luck? Microsoft Home Publishing and Microsoft Publisher are two completely separate, different, and unfortunately similarly-named applications. Their filetypes are incompatible. -- Ed Bennett - MVP Microsoft Publisher http://ed.mvps.org Dad of 5 wrote: > At school kids have PUB 03 or 07 file they created and at we have...

Problem in saving Date and $ field in Excel to CSV file
We just copy and paste data from MS Access 2003 to Excel 2003. When we save the Excel as CSV file, we find that the date has been converted to American format. We have checked the Regional Settings and Australia is used. Is there any language setting in Excel ? Moreover, on another machine, we are able to save to non-American date. However, we find that for monetary field, most of them are quoted - Like "$2,000.00" but some are not quoted - like $580.00. Your advice is sought. Thanks Peter ...

XML as parameter in webservice
I have written two simple webservice functions and trying to consume them through a client piece. Both the webservice functions have similar signature. -------------------------------------------------------- public string quoteNew(System.Xml.XmlNode passedXML) and public string EmitXml(System.Xml.XmlNode passedXML) --------------------------------------------------------- These two functions are defined in the same namespace and same class. So, in the client piece I have written code to acces these webservices as: ----------------------------------------------------------- --...

Sharing a XL file
I need to share a macro on a network on a read only basis, but when it is opened by anyone I can not write to it. How can I write to it when it is opened by someone? ...

convert pub 2000 doc into a pdf file
how can i convert a pub 2000 file into a pdf doc so that i may email it to people who don't have publisher? Thanks! While in a state of ecstasy after repairing his laptop, Ed sees a message from regi k <regi k@discussions.microsoft.com>. On it is written: > how can i convert a pub 2000 file into a pdf doc so that i may email > it to people who don't have publisher? You need to use a program like PrimoPDF (www.primopdf.com) or Adobe Acrobat (www.adobe.com/acrobat) to do this. PrimoPDF is free, Acrobat isn't (you can't create PDFs using the free Acrobat Reader) ...

How to get Preview Pane in separate Data File in Outlook 2002
For back-up and portability purposes, we use separate Outlook Data Files. (File, New, Outlook Data File, ....) Then we use the Organizer Wizard to move files from the Inbox to the appropriate data file. All of this works great. The only thing we can't figure out is how to turn on the preview pane on one of these files. It works fine on the standard InBox or any Personal Folder that is in the main *.PST file. We use the described method (View, Current View, Other Settings, check by Preview Pane) and we don't get any error message. However, we also do NOT get ...

Trying to log into OWA
When I try to login to OWA, my inbox won't come up. It is stuck on loading. I am using IE7. Any idea why? -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.aspx/ms-outlook/201004/1 This is an Outlook group. OWA is an Exchange application. Ask in an Exchange group. -- Russ Valentine "Shawn76 via OfficeKB.com" <u57604@uwe> wrote in message news:a65f817e43528@uwe... > When I try to login to OWA, my inbox won't come up. It is stuck on > loading. I > am using IE7. > > Any idea why? > > -- > Message p...