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

Similar Articles

[PageSpeed] 52

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 (1778)
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:

Parsing Question
I've done parsing where you have one delimiter such as a comma or space. What if you have more than one? Example data: sStr(0) = "3/9" sStr(1) = "3/11 3/15-" sStr(2) = "3/8+ 3/12" sStr(3) = "3/9 3/15" sStr(4) = "3/8- 3/10+ 3/15" The strings above are Month/Day with some having an additional - or + character next to it. These dates are extracted from Excel cells as strings. I need to break those strings down into individual dates. So for sStr(4), I need to parse out "3/8", "3/10" and "3/15&...

Email file corrupt?
Yesterday I somehow managed to erase the boot sector from my HD and it took a whole day to recover my partitions which were left fully intact. My system had been in hibernation mode before that, but when I got back to the windows desktop I found I was frozen out (even task manager wouldn't come up) and I had no alternative but to reset. Problem was, outlook express was open when I hibernated. When I reset, I started outlook and all seemed fine. A couple of hours later though, I started getting GPFs (or whatever XP calls them) when I tried to reply to email, or double click one to view ...

Changing the Money 2004 data file a Pocket PC uses
I have Money on my Pocket PC. I was satisfactorily synchronising with Money on my desktop. I had to change the data file on the desktop. Having done that, I deleted the old data on the Pocket PC. However, when I go to load from the new file, only one Money Account (eg Visa, Cash, etc. shows up in the list from which to select those to synchronise - Investments to Watch. (On the page found by selecting 'Microsoft Money' in the list in ActiveSyn.) Can anybody save me the $50 minimum Microsoft wants to charge me? (Which is a bit stiff given that Money 2004 is not a product...

Problem opening serialized file via Open command associated with file type
I have an SDI MFC application that produces a serialized project file via CObject's serialization support. The application can read the file from within the application just fine. The installer registers the program and the file extension properly and associates the file type with the application. However, when I double click on the project file, the application generates an "Unexpected File Format" message. Is there a method in the document class that needs to added to handle this functionality? I want to try and debug the problem but not sure how to invoke the debugg...

Inserting files into excel worksheets
Why is there no option for inserting an files into an existing Excel worksheet similar to the option forinserting files into Word and PowerPoint files. I work for a CPA firm and this would be a valuable feature feature. "ccwies" <ccwies@discussions.microsoft.com> wrote in message news:FFC33867-4C40-45F8-89E0-540ABD94AC3C@microsoft.com... > Why is there no option for inserting an files into an existing Excel > worksheet similar to the option forinserting files into Word and > PowerPoint > files. I work for a CPA firm and this would be a valuable feature feature...

Sync Outlook files
Using Outlook 2003 Can anyone tell me an easy way to sync a laptop outlook files with my desktop's outlook files. Thanks Check out http://www.slipstick.com/outlook/sync.htm -- PATRICK REED [Outlook - MVP]~~~~~~ -Microsoft Certified Professional (MCP) -Have you checked http://www.slipstick.com? -Please post your Outlook version! "Shane Nation" <Shane@nation22.freeserve.co.uk> wrote in message news:ulHTz1%23PEHA.624@TK2MSFTNGP11.phx.gbl... > Using Outlook 2003 > > Can anyone tell me an easy way to sync a laptop outlook files with my > desktop's ...

how to parse <?xml version="1.0" encoding="UTF-8"?> with xpath? is it possible?
how to parse <?xml version="1.0" encoding="UTF-8"?> with xpath? is it possible? "Daniel" <softwareengineer98037@yahoo.com> wrote in message news:%23g11DbDOGHA.2176@TK2MSFTNGP10.phx.gbl... > how to parse <?xml version="1.0" encoding="UTF-8"?> with xpath? is it > possible? No -- the xml declaration is not represented in the XML Infoset. Cheers, Dimitre Novatchev ...

Parsing cells
Hi Folks, I have data in cells which is OCR`d from my phone bill, and some of the info is corrupt. Where I should be getting eg. 17 Nov 14:49 for date/time I am getting O17 Nov 14:49 or C17Nov 14:49. The reason is that there are unreadable icon characters to signify day or night. Questions: 1)How do I remove the faulty characters......they are always the first digit in the date if they are there. 2)How can I seperate the date and time into two adjasent colums of cells rather than their current format in one cell. Any and all help greatly appreciated. John Hi John You ca...

Parse Nested Elements to Single DataGrid
I have been losing my mind trying to parse an XML document (with nested child elements, not all of which appear in each parent node) into a DataGrid object. What I want to do is "flatten" the XML document into a text document with a single row for each parent node (that has all of the values from all of the child nodes for that row) The DataView within VS 2005 IDE displays my 15 or so child tables - and knows that some parent rows don't have child rows in every relation - but trying to get all the child tables to go with the correct parent row programmatically is killin...

Access data in a money file...
Hi all, First time that i post a message to that group.... I'm trying to access the data stored in a money file as i suppose it is stored in a database manner... Does anybody know of a way to do so through ODBC or something similar ???? thx laurent See http://www.bollar.org/msmoney/#Q10 and http://www.bollar.org/msmoney/#Q9. "Laurent Ades" <turkpipotutunu@ifrance.com> wrote in message news:6af9c352.0310100130.27458bdd@posting.google.com... > I'm trying to access the data stored in a money file as i suppose it > is stored in a database manner... > > D...

Problem when trying to pdf publisher file
When trying to pdf a publisher file it comes out being about 7 times larger than the publisher file. Too big for email which I need. Why is this? Thanks, Stephanie Stephanie wrote: > When trying to pdf a publisher file it comes out being about 7 times > larger than the publisher file. Too big for email which I need. Why > is this? Thanks, > Stephanie With the wealth of infomation you've given, I'm sure you'll have people clamouring to assist you. Why don't you start by answering some basic questions: - 1) What version of Publisher are you using? 2) ...

Upadate page element across multiple pages/files?
Simplified Scenario: You're creating wire frames for a web site. You've got 5 menu items and 5 files (each file representing the different content for each menu item). You find out you need a 6th menu item. How do you add the 6th menu item to the menu and have it update all five of the other files? Perhaps using 5 "pages" in the same file, rather than 5 separate files? I checked into "Templates" and "Styles" in the help documentation... but no luck. I know this is possible in HTML editors like DreamWeaver UltraDev. Suggestions? Thanks, bk I figured ...

Opening excel files
Hi everyone If I open an excel document from my documents, or other location, excel opens but then the file does not open. I can open excel files from excel and using the open command. but not staright from my documents. Any ideas? thanks Sometimes one of these works when you're having trouble with double clicking on the file in windows explorer: Tools|Options|General|Ignore other applications (uncheck it) --- or --- Close Excel and Windows Start Button|Run excel /unregserver then Windows Start Button|Run excel /regserver The /unregserver & /regserver stuff resets the win...

When saving CSV excel always prompts about the file format
I work with a lot of csv files all day and they have to be this format for other applications and scripts to use them. Everytime I save Excel prompts "filename.csv may contain features that are not compatible with csv, do you want to keep this format". This is the case even with Control S. The only formating is that I make the columns big enough for me to read whats in each cell. Anyway - can I turn off this prompt so that Excel just saves the file as csv? Thanks, Simon Try this before the save Application.DisplayAlerts = False and reset it after the save Application.Di...

Problem when export a report to a pdf file
I use the following code to export a report to a pdf file : ' Open report as hidden DoCmd.OpenReport p_NomEtat, acViewPreview, , p_CondtionWhere, acHidden ' Print toPDF DoCmd.OutputTo acOutputReport, p_NomEtat, acFormatPDF, p_NomFichierAvecChemin, p_OuvrirDsReader ' Close Report DoCmd.Close acReport, p_NomEtat The second line (docmd.outputto) isn't working with a error (Error n° 2501 : Action cancelled) Please notice that i've got another message (""File Opened by another user" which of course is wrong as the file...

Error log 7004 and 7010
Hi All, My exchange servers constantly receiving error log 7004 and 7010, I read the article 843106 and 324059. But they are not helping. I have disable the reply function for the Protocols > SMTP > Default SMTP Server > Access Tab > Relay button > select only the list below( the list is empty) and also unchecked the box of "allow all computers which successfully authenticate to relay, regardless of the list above" on both of the servers. But the message is keep coming back. I have two exchange 2003 servers(run on windows 2003 server) on two different doma...

PAB File
I have a Network address book in Outlook 2000 that I want to import to my home computer. I am running Outlook 2000 at home with Internet mail. How can I do this? ...

Long File Names in Office.X
> This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --B_3156168936_2862024 Content-type: text/plain; charset="ISO-8859-1" Content-transfer-encoding: 8bit My OS X system supports long file names just fine, but when I open these files in Office they get truncated to something with a code at the end, such as #4587. I researched this and there is logic to the code (according to Microsoft), but it is a real pain when I am sharing files with Windows users and their systems support these long file na...

inserting wav files
I am making a spreadsheet in which I want to include sound icons which will play a predetermined wav file when double-clicked (or otherwise activated). I have tried imbedding objects which works pretty good, but every time I double-click on the icon, not only does it play the sound file (good) but it "activates" the picture for editing (the box with the handles) (bad). I would appreciate any methods to correct this, or other ways to imbed sound files in a spreadsheet. Thanks! Boatman Boatman, I haven't messed with EMBED. The Playsound method will play short wavs, but if t...

Can't open mny files
I recently had to reformat and reinstall all my programs, including Money 2005. I carefully backed up all my important files, including mny files and the backups. I reinstalled Money 2005, and the program won't open, saying alternately that the files are from Money 2004 (???) and that it can't find them. I can't open the program at all because it keeps going round and round about the files. I really don't want to just delete them and start all over if there is another way out of this. Any help out there? TIA - sheureka See http://umpmfaq.info/faqdb.php?q=177. "s...

Parsing CSV
Hi, im using A file with records in my mfc application, i need to read*/write records to the file anybody ahs a clue where should i start? Take a look at CStdiofile and CString::Format() (for output) and CString::Tokenize() (for parsing input). You can use ReadString() and WriteString() to access the file line by line. Tom "fima" <fkpkot@gmail.com> wrote in message news:eXA9vp95FHA.1184@TK2MSFTNGP12.phx.gbl... > Hi, > im using A file with records in my mfc application, i need to read*/write > records to the file anybody ahs a clue where should i start? >...

Pub 98 not opening earlier files
I have publisher 98 and can not get it to open files I have saved made on an earlier version of publisher. Is there a way to open these files created with an earlier version of Publisher? Do you get an error? Do you have Norton, if so disable script blocking. Publisher 98 should open all earlier files expect Publisher 1.0. -- Mary Sauer MS MVP http://office.microsoft.com/ http://www.msauer.mvps.org/ news://msnews.microsoft.com "Larry" <lbeckley@tampabay.rr.com> wrote in message news:362601c4a044$eee45c20$a501280a@phx.gbl... >I have publisher 98 and can not get it to...

Parsing
Hello, I have an Excel application where I read a text file.Recently the text file had a change and had three(3) new fields added.This data is now in the last column.I want to parse this data which has a space delimiter into three seperate columns.There are 10 fields and the data is captured in the last column.How do I do this in VBA without the "text to column" manual method. Thanks, Roy Try using the VBA TextToColumns method... In article <1193081380.394989.87940@q5g2000prf.googlegroups.com>, Roy <praish1998@yahoo.com> wrote: > How do I do this in VBA without...

outlook .dbx files
I have old .dbx files/folders with as much as 654,000K in them. Are these old emails and if so, how can I access them to see what they contain? ...

PDF files in Outlook XP
I recently upgraded Acrobat Reader to 6.0. I'm running Office XP SP3 in Windows 2000. Since the upgrade, pdf attachments sent to me have generic icons and the file cannot be opened unless I save it to disk first. I receive many of these daily and saving to disk is not efficient time-wise. Is there a fix or patch that will allow me to open these pdf files? I did not have this problem with Acrobat 5.0. Reinstalled Adobe Acrobat already? File associations are not done by Outlook but are managed by the program that supports it itself. You can overrule it by going to Control Panel-...