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
2063 Views

Similar Articles

[PageSpeed] 10

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:

help with log file
Got a database in SQL2005 that is basically a download of a daily flat text files and creating tables from them. The log.ldf file is frikkin huge. It's over 146GB and I don't need this, I have storage issues. How do I shorten down this file and keep it small forever? Hi Rocketman Have you read about managing the transaction log in the Books Online? How big is your database? What recovery model are you in? What kinds of backups are you doing, and how frequently? If you are not in SIMPLE recovery, and you don't back up your log, it will continue to grow. Even...

Impersonation and Custom Event Log
Hi, I have created a Custom Event Log. My ASP.NET application is impersonating a specific Windows Account that currently has no permissions on the web server, apart from Modify access to C:\WINDOWS \Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files. I cannot currently write to the event log. I am using the Logging Application Block. What is the best practice way of writing to the event log when using impersonation? I'd like to do this from within ASP.NET if possible and I want to avoid raising permissions as far as possible. Cheers, James ...

Replace a comma with a period in a cell containing a lastname, first name, middle i
Hello - I am trying to clean some data and need to change all of my names from McLaughlin, Victor, (i.e, comma) W to McLaughlin, Victor.(i.e., period) W Is there an extract and replace formula or method of som sort (in excel or access) that will allow me to pull the first comma from the right and replace it with a period. Thanks for any suggestions! Select the cells you want to change and run this tiny macro: Sub comma_tose() For Each r In Selection v = StrReverse(r.Value) r.Value = StrReverse(Replace(v, ",", ".", 1, 1)) Next End Sub For example: a,b,c,d wi...

Folders disappearing after compacting file cabinet
Twice, now, I've lost a good chunk of e-mail I've saved in different folders because I've compacted my file cabinet. Anything with a file folder named with E or beyond gets dumped. A through D only remains. Any ideas as to what's going on? Thanks! Karen C. Did you compact or run ScanPST.EXE? I've never heard of a compact deleting valid data unless, of course, the file was damaged before running the compact. I hate to ask but do you have a backup of your PST from before this happened? "Karen C." <kcunningham @ iglou.com> wrote in message news:...

MS Excel file extension changed through e-mail
MS Excel .xlsx files sent as attachments are received without the x, as a .xls instead. The same is true for MS Word .docx changed to .doc Answered in the Word group. Please don't post the same question in multiple groups. It not only causes responders to waste their time replying to questions that have already been answered but it also makes it more difficult for you to follow up on the replies. If it truly is an issue that involves more than one app either post to the Office group rather than the individual groups or use a newsreader rather than the web interface & learn to ...

Dump file corrupt
************************************************** ************************ THIS DUMP FILE IS PARTIALLY CORRUPT. KdDebuggerDataBlock is not present or unreadable. ************************************************** ************************ Unable to read PsLoadedModuleList ************************************************** ************************ THIS DUMP FILE IS PARTIALLY CORRUPT. KdDebuggerDataBlock is not present or unreadable. ************************************************** ************************ KdDebuggerData.KernBase < SystemRangeStart Windows XP Kernel Version 2600 ...

Log into GP 10
We are going to GP 10 soon, it is currently on a test machine. I have created a user, added to a role, with the relevant access. But, when I try to log in, I am going past the login screen, I am seeing the company access, but after that there is a blank screen. Please help, what have I missed? I have seen this happen before and it has to do with the Home Page not being populated. A couple of things to check, first make sure the user has been assigned the DEFAULT USER role - if that doesn't work, try deleting the user and then when you add them again select a home page rol...

Network File lock not detected
We have a workbook that about a dozen people get in and out of all day. I have a problem with one user's excel not always locking the file, or it could be a problem with other users not detecting the file is in use and displaying the in use message, do you want to open a read only or wait. Is there anything I can do in execel to fix that or is it a network issue. Running XP pro, office xp pro, and 2k server. From my experience, it is a network issue. They need to unlock the file because Excel cannot. Fixed it, Windows didn't have sp1 on it. For some reason it fixed the pr...

XSD/XML -> RDB in .Net
Hello all! Are there available samples or code which can create "create table" SQL statements using provided XSD and/or XML? Is it possible to get create table statements from DataSets / DataTables in ..Net? Any ideas how to approach this? ...

How to update contacts in WLM via csv file?
I have nearly 2,000 email addresses in my contacts list. I managed to get WLM to list them, although I do notice some are missing. Now, I want to update them with new/revised contacts through a new cvs file, which I exported from OE. However, the contacts import program just hangs and doesn't take. Do I need to delete the existing list first? If so, how do I do that? I am using WLM v.2009 Build 14.0.8 on Windows 7 Are you logging in to Live services? It will say your profile name under the close X. -- Ron Sommer "Bumper21248" wrote in message news...

pst file might be corrupted
Hi all. I am not able to view my pst file at all via my outlook 2000. I tried to recover it via scanpst but scanpst stopped halfway through the process and said that an error occured without specifying which error. Is there any other way to recover this pst file? Thks in advance. How big is the PST file? "inenewbl" <inenewbl@discussions.microsoft.com> wrote in message news:6FB884E0-7C9F-4064-936F-5065E257BB5B@microsoft.com... > Hi all. I am not able to view my pst file at all via my outlook 2000. I > tried > to recover it via scanpst but scanpst stopped halfway ...

VBA to call file based on date
Hello, I wonder if anyone can help me with a VBA routine to check for the presence of a specific file. The file is saved on a dialy basis in the format "userfile_run_YYYYMMDD.xls" i am seeking help with a vb code that will check if today or any specified days report is generated. i guess excel can use the date format to read the specified location for the file. Thank you in advance for your help. .....Coming from Where I'm from. Dim sFile As String sFile = Dir("C:myPath\userfile_run_" & Format(Date,"yyyymmdd") & ".xls") If s...

"The image file ___ is valid but ...."
"The image file ________ is valid but is for a machine type other than the current machine." What does this message dialog mean on Win XP x64? It means that the program you're trying to run is 16-bit. There is NO 16-bit support in any 64-bit version of Windows. You'll need to run the application in a virtual machine running some earlier version of Windows. -- Charlie. http://msmvps.com/blogs/russel <johnsuth@nospam.com.au> wrote in message news:c1.2c.3KklK9$0TP@PC1.BIGPOND.COM... > > "The image file ________ is valid but is...

replace invalid xml characters
I know that System.Security.SecurityElement.Escape() will replace invalid xml chars with valid equivalent ... But is there another method to accomplish same that is "closer to home" ? * John A Grandy wrote: > I know that System.Security.SecurityElement.Escape() will replace invalid > xml chars with valid equivalent ... > > But is there another method to accomplish same that is "closer to home" ? > > I usually use the stream editor "sed" for this type of stuff. John A Grandy wrote: > I know that System.Security.SecurityElement.E...

print mass Powerpoint certificates from Excel file
I get Excel lists of students that require training certificates. I have a PowerPoint certificate. Is it possible to do something simular to a mail merge? In article <BFBA41AC-26D1-4B30-8C54-425C2E8A50F0@microsoft.com>, Go to Girl wrote: > I get Excel lists of students that require training certificates. I have a > PowerPoint certificate. Is it possible to do something simular to a mail > merge? Not out of the box, but we have a commercial PowerPoint add-in that does exactly this. You can try out a fully functional demo to see if it meets your needs. Mo...

Can Import Email Data Filed from Office XP to Office 2003
My HD failed but I had a backup of my Office XP Pro personal file folder with a lot of emails I needed. The file is about 128MB in size. I put a new HD in and installed Office 2003 Pro. When I go to open the old file Outlook 2003 says that the file "is not a personal folders file". (It was backed up to a CD ROM prior to the crash so the source file should be good.) I really don't want to uninstall Office 2003 and put back Office XP. Any idea why 2003 won't open the file and how to work around that? Many thanks in advance to anyone who knows the solution. Alan. The only pro...

How to open saved .DBX files?
I saved a folder of e-mails to CD from Outlook Express shortly before my last computer died. I desperately need to open the folder (saved as a .dbx file) by tomorrow, to get my husband (in Portugal watching the footie) the details of his hotel!!I am now running Xp and have both outlook and outlook express(office 2003) I tried open with, but selecting OE takes you into the OE files rather than selecting it as a prog.If I try open with outlook, it just appears as a folder attachment in an e-mail Can anybody help me open this wretched thing??? Ask in an Outlook Express forum. This is an...

Size mismatch between stm/edb files and mailboxes
I am puzzled! Am running out of diskspace on our exchange drive and badly need to reduce the size of the exchange database. The total size of the priv1.edb and stm files is approx 6Gb. If I add up the total size of all the mailboxes as shown in ESM it comes to approx 1.5 Gb. Running eseutil /ms and calculating the free space for both files gives me approx 1.2Gb, which is what I believe I will regain by defragging the store. So where is my remaining 3.3Gb gone!!!! The online maintanence is completing fine each night. Deleted item retention is set to 0, and we haven't deleted any ...

Sync Money Files
I have a laptop and desktop, both running Money 07. I have been away from home for three months and have been keeping my expenses in Money on my laptop. My wife has been keeping our records on the desktop. My problem is how to combine the two files so that I have one set of money files. When I cease travelling, the notebook will not be used for Money work; but the desktop will. So I need to combine the two files. Are there any solutions? Thanks, John Reid There is no easy way to do this. There aren't even many hard ones. Have you already done this or are you only pondering a re...

"Get-ClusterResource" cmdlet throws "not recognized as a cmdlet, function, operable program, or script file" error.
Hi, I am trying to use "Get-ClusterResource" cmdlet to fetch "File Share Witness" property of CCR cluster. But when I run this command no "Exchange Management Shell" I am getting "The term 'Get- ClusterResource' is not recognized as a cmdlet, function, operable program, or script file. Verify the term and try again." error. Any idea why I am getting this error? Do I need to add any "PSSnapin" via Add-PSSnapin cmdlet ? If so which one it is? Basically I am not able to run any of the cluster related GET cmdlets on Exchange Managem...

Read partial xml into dataset
Hello I need some help to read only partial nodes of a xml and store it as a dataset. In my example below, I need only the values within the nodes <WorkFlowStepHistory> in a dataset. I'm sure it is pretty simple, but since I'm new to xml not sure how it is done. Say my xml string has nodes like <RequestSpecificData> <OtherNodes> ------- </OtherNodes> <WorkFlowStepHistory> <WorkFlowStatus>FormSubmitted</WorkFlowStatus> <WorkFlowStatusDateTime>12/17/2007</ WorkFlowStatusDateTime> ...

Default Workgroup Information File
What's the difference between the two following choices using Security Wizard? "I want to make this my default workgroup information file." & "I want to create a shortcut to open my security-enhanced database." Does one of these apply this security to all databases? I noticed that it applies the security to my backup database that I keep on my desktop. The security is originally applied to a database that I keep in a shared network file. -- julostarr "julostarr" wrote: > What's the difference between the two following choices using Secu...

How to tell if folder item is file or folder?
Hi all. Now I am processing data in folders. I get a listing of folder contents and have to test to determine whether item is folder or file. I have this routine: strPath is previously set with valid data, strType is previously defined. Dim objDI As New System.IO.DirectoryInfo(strPath) For Each objFSI As System.IO.FileSystemInfo In objDI.GetFileSystemInfos() If objFSI.Attributes() And IO.FileAttributes.Directory Then strType = "Folder" Else strType = "File" End If Next My question is whether this is the...

Data vanished, Large file seems empty
I opened Outlook this AM and it was as if I had never used it. My created folders were gone, only the default folders were there and they all were empty. I tried to open the proper .pst file and found one with 91,360kb, but whether I try to open it through Outlook/File/Open or simply double-click the file from Windows Explorer I get the same results: ghost-town Outlook, empty folders, etc., like I'd never been there before. Try running the Inbox Repair Tool against your .PST file to see if it finds any errors. Search your drive for a file called scanpst.exe and run it. -- Jocel...

SOP Invoice: Custom footer based on logged in user or customer cla
I've been asked to determine if its possible to conditionally print footers on SOP Invoices to indicate the contact info of the person responsible for the client company. I was looking at either using the current logged in user or the class of the customer to determine which info to include. Can anyone point me to a KB article or some other source that can show me how to do this? Unforunately the user-defined fields in the customer record have already been dedicated to something else. TIA! VinceV You can attach some VBA code to the report and use the RetrieveGlobals.dll supplie...