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

Similar Articles

[PageSpeed] 50

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:

Hyperlink has changed on file re-opening
[Excel 2002, Win XP Pro] Hi All, i have cells in a sheet whose cell contents are hyperlinked to wor documents. the hyperlink is generated using VBA. part of the fil name includes the '[' and ']' characters (square brackets) when the macro is run, everything works fine (click in one of the cell and the appropriate word file opens) BUT when the workbook is closed an re-opened, the '[' & ']' is changed to '%5b' and '%5d' respectivel (which i guess is some srt of charatcer code for those symbols) if the hyperlink macro is re-run, it 're...

how do I create qif files from Excel for import into Quicken?
Want to import a bunch of financial data that's in Excel into Quicken. Can I create a QIF file from Excel? You'll need a converter utility for this. Here's a google search that might help: http://www.google.com/search?sourceid=navclient&ie=UTF-8&rls=GGLD,GGLD:2004-31,GGLD:en&q=convert+excel+to+quicken tj "pb" wrote: > Want to import a bunch of financial data that's in Excel into Quicken. > Can I create a QIF file from Excel? Hi *pb*, See if http://xl2qif.chez.tiscali.fr/xl2qif_en.php suits your purpose. Don't forget to back up the folde...

Contacts File Link?
I have several computers on a home network and WLM does a fine job of keeping the contacts in sync on all the computer. I am giving one of the systems to a friend. What is the best way to un-sync the contacts file on the system that I am giving away so they can have there own contacts file? Uninstall WL and reinstall with a new WL ID or Passport? Create a new Windows user. Remove the old user. -- Ron Sommer MS MVP- Windows Live Mail "Ken" <krlorenz@comcast.net> wrote in message news:2099F8C5-9BCE-4229-A3D2-5187C1F4FFF9@microsoft.com... > I have several...

Export to Text Files Based on Field Value
I have an Access table with personal information (e.g., first name, last name, birth date, etc.) for thousands of people. The table is sorted by state. I want to be able to run a macro on that table that will create separate pipe delimited text files for each state with all fields included. Any help would be appreciated? -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access-queries/201005/1 Instead of exporting the table, export a query based on the table. You will have to have some code that loops through the states and modifies the quer...

How to import Eudora files into Outlook
I've searched the forum, and everyone seems to have already been able to bring their old Eudora files into Outlook. I am now trying to do this but cannot figure out how. I'm not even sure exactly where to find my Eudora files, much less get them over to Outlook 2007. Can someone help me here. My hard drive crashed last Friday and I have rebuilt a new one except for my email program. I have been using Thunderbird temporarily, but I really don't like it. My Eudora files are saved to a hard drive and Thunderbird imported them with no problem. But I can't for the life of me figur...

Is there a way to extract files from the Off line files cache
I have a laptop that used to be a member of a SBS 2003 domain and was utilizing folder redirection of My Documents. The laptop was never reconfigured to remove it from the domain and the user continued to use the domain login. Since that time (about a year ago), the computer and user were removed from the SBS domain. So far so good, the user on the laptop was happy.. Today, the laptop was worked on and was removed from the domain. Now, the question is, where are the files that used to be in My documents? I beleive they are cached in the Offline files folder (C:\wind...

File Stuck In Outbox
I have a 6 MB file that can not be sent or deleted from my inbox. I followed the "Assistance" suggestions on the MS web site but had no luck. Any idea? http://www.outlook-tips.net/howto/recover_deleted.htm -- Diane Poremsky [MVP - Outlook] Author, Teach Yourself Outlook 2003 in 24 Hours Coauthor, OneNote 2003 for Windows (Visual QuickStart Guide) Author, Google and Other Search Engines (Visual QuickStart Guide) Outlook Tips: http://www.outlook-tips.net/ Outlook & Exchange Solutions Center: http://www.slipstick.com Join OneNote Tips mailing list: http://www.onenote-tips.net/...

How to delete a .mny file...
I'm new to Money 2003. I imported Quicken 2002 data, and for some reason, one or two accounts did not completely transfer. I repeated the import and opened a new Money file (with a new name.) This time it went smoothly. Simple question: can I just delete the old Money file I first created? Is it as simple as going to "my computer" and deleting the appropriate .mny file? Thanks for any response. EL In microsoft.public.money, EL wrote: >I'm new to Money 2003. I imported Quicken 2002 data, and >for some reason, one or two accounts did not completely >...

convert or open .pub file
I have recieved a file with a .pub extention. I do not have publisher, any ideas on how to open it, and readers that I can download. No trial is offered for this program to download? I tried acrobat distiller (microsoft said it would work) but it dosent work thank corey corey wrote: > I have recieved a file with a .pub extention. I > do not have publisher, any ideas on how to > open it, and readers that I can download. ================================= Best bet would be open it in the Publisher version that created it. There are no Publisher viewers. Here's some info you ma...

Unable to run excel macro after changing file name
After changing the filename in an excel macro, receiving Error number 5 - Invalid procedure call or argument when users with excel 2000 run the macro. Users with excel 2003 are not having this issue Post the line of code that is causing the error. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "merf" <merf@discussions.microsoft.com> wrote in message news:F68DF323-214D-4F01-8D8E-654F9500242E@microsoft.com... > After changing the filename in an excel macro, receiving Error > number 5 - > Invalid procedure cal...

Help with Links to Files
Hello, I have a file in Word 97-2003 compatibility mode. When I select the Office Button / Prepare I see an option to Edit Links to Files. If I convert the file to 2007 format the option for Edit Links to Files is no longer there. Where did they go? thanks, mitch This is strange. The Edit Links to Files option should be available even if you save in Word 2007 format. Are you sure you didn't inadvertently break the link to the automation object? You could press Alt+F9 to see that the field code for the object is still intact. (Note that you can only see the field co...

Seam-Excel error when exporting file
When I export an excel file from a website the file exports with the file name of 'seam-excel' and I can't format the cells or create a pivot table without saving and re-naming the file. How can I get my file to not export with that file name? Is it a security setting? Have never heard of this problem being generated through Excel alone. I would suggest the source would be at the website from which you are exporting. Can you post a URL? I'd like to have a look just out of curiosity. Gord Dibben MS Excel MVP On Fri, 12 Feb 2010 12:41:01 -0800, fallou...

Write XML and simulataneously verify
Hi I have a XSD and an app. that gives some output which I need to be formatted in XML format(schema being a pre-defined XSD). I know how to write an XML file using XMLTextWriter and also to validate it using using XMLValidator. But is there a way to validate simulatenously as the XML is being written using XMLTextWriter?? Best Wishes -Aayush Validating XmlWriter doesn't exist yet. The only way you can do schema validation is to use XmlValidatingReader on top of XmlTextReader. My suggestion is to save output into text stream and reparse it with XmlValidatingReader. Yan "Aayush P...

Comparing two excel files
I work with large data in excel. Most of the time I need to match two different worksheets. Both worksheets always have two columns that contains same data (name & ID). What would be the best way to match names and ID to obtain a new file with data that couldn't match? if Excel good to do that or should I use other software like Access? please advise. Look at Chip Pearson's page on working with Duplicates and Uniques http://www.cpearson.com/excel/duplicat.htm -- Regards, Tom Ogilvy Alexandra <anonymous@discussions.microsoft.com> wrote in message news:1091601c3f335$a...

Flat files to XML
Hello all, How can I convert unstructured flat files into structured XML? Are there any scientific articles and tools that handles this subject? Bye, hakhan Check out http://tinyurl.com/4vgn8 creating custom XmlReaders is a nice way to deal with with CSV or Fixe width files, although don't know exactly what you mean by unstructure files.. - jsm3 ----------------------------------------------------------------------- Posted via http://www.mcse.m ----------------------------------------------------------------------- View this thread: http://www.mcse.ms/message1165932.htm ...

Transfer file from Access to Server
I work with Access 2007 as a front end to a SQL Server backend. I would like to be able to select a file from my local desktop, then, through VBA/SQL transfer the file to a folder on my server. Or, store the file in a varBinary(MAX) column in a table, but then use a SPROC to take the file out of the table and place it in a folder on the server. How can I do this? -- Bill The built-in VBA sub FileCopy() will allow you to copy a file from one folder to another. If you want to provide a dialog that allows a user to select the file then have a look here: http://www.mv...

How can I convert an Excel file to an address book?
How can I convert an Excel file to an address book to import into email? ...

Nested XML and DataSets
Hello, I have the following XML file: <events> <event name="event1"> <sessions> <session date="23 Feb 2004" time="10:00 - 15:00" location="Toronto" /> </sessions> </event> <event name="event2"> <sessions> <session date="25 Feb 2004" time="10:00 - 15:00" location="Toronto" /> <session date="26 Feb 2004" time="10:00 - 15:00" location="Toronto" /> </sessions> </event> </e...

Saving xml with accentuated characters
Hello, All! I'm working with accentuated characters in my XML files, and I have found problems to load and save it. First, for this case, I always have my XML in memory, and I load it via LoadXML (please, ignore incorrect concatenations for this sample): Dim cXml As New Xml.XmlDocument Dim strXML as String strXML = "<?xml version="1.0" encoding="ISO-8859-1"?> <SETTINGS> <COLUMNS> <COLUMN INDEX="Code" WIDTH="0" Alias="C�digo"> </COLUMN> </COLUMNS> </SETTINGS>" cXml.LoadXml...

Create a flat file in Excel
I need to create a flat file in Excel using the pipe delimiter | as element, and carriage return line feed as line delimiter. How do I do this? You could change the windows list separator (in the regional settings applet in the control panel) to the vertical bar (just temporarily). Then save the file as a delimited file. Or maybe you could create a formula in another cell: =a1&"|"&b1&"|"&c1&.... And drag down. Then copy that column and paste into notepad and save the file from notepad. GF08 wrote: > > I need to create a...

Automatic Filing of messages that have just been Read
The Rules Wizard does not have the option to allow me to define a rule to automatically file a message that I just read. I would like to take a file that is in my Inbox, read it, and the next thing I know it is filed in a personal folder I call "ReadMessages". I don't want to have to move the messages manually as I read them. Any suggestions? On 10/21/2003 11:19 PM, Sid Pollock wrote: > The Rules Wizard does not have the option to allow me to > define a rule to automatically file a message that I just > read. I am not too sure if this can be done. However, ...

Can 2 users use the same Outlook XP .pst file??
Hi, My computer has 2 different user names. Is it possible for both users to use the same Outlook (XP) mail files? If so, does anyone know how? Thanks Different users can share the same pst file as long as they both have access to the file and they don't access the pst file at the same time. "Dave" <anonymous@discussions.microsoft.com> wrote in message news:002901c3cc29$c39da5c0$a001280a@phx.gbl... > Hi, > My computer has 2 different user names. Is it possible > for both users to use the same Outlook (XP) mail files? > If so, does anyone know how? > >...

Choosing File Details to Include
When syncing my device through WMP using WMA files all the file details (such as artist name, album name) were transfered with the file. However, when I tried to sync MP3 files the only info that transferred was the file (song) name - it also had included the the track# as part of the song name. Last night I THINK I came across a window where I could check off which details to include and also had the option to remove the track # from the song name. Today I cannot find that screen anywhere. Where would I have seen such a screen and how do I find it again? Thanks -- ...

Using C# to conver XML into Excel ?
Hi Experts: Anyone knows if C# provide functions to convert XML file into Excel format? Thanks Polaris Hello! > Anyone knows if C# provide functions to convert XML file into Excel format? Do you mean the Excel XML format or the "old" Excel binary format? The first one should be easy to create with XSLT (see System.Xml.Xsl) the second with Office-Interop or special third-party libs. -- Pascal Schmitt ...

Publisher98 won't open Publisher95 file.
Hi, A friend of mine wanted me to review at his first publication before he prepared it for printing. The problem is that when he sent me the file it I was unable to open it. I looked in the file properties to discover that he uses Publisher 95 version 5.0. I use Publisher98. Is there a way to fix this? I searched Microsoft's website for a converter or upgrade that would allow this, but I've had no luck so far. Thanks. Ruthie :) Is the file you are tying to open on your hard disk or a floppy? -- JoAnn Paules MVP Microsoft [Publisher] "Ruthie-chan" <ruthiecha...