Main Page | Report this Page
.NET DotNet Forum Index  »  XML Forum  »  Parse log file containing Xml...
Page 1 of 1    

Parse log file containing Xml...

Author Message
Lee...
Posted: Thu Nov 05, 2009 6:19 am
Guest
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
 
Martin Honnen...
Posted: Thu Nov 05, 2009 12:57 pm
Guest
Lee wrote:
Quote:
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/
 
Robert Aldwinckle...
Posted: Thu Nov 05, 2009 10:48 pm
Guest
"Lee" <lee.keable at (no spam) gmail.com> wrote in message news:f15a56db-dcaf-48a7-bafd-ba4fcbd029d6 at (no spam) r24g2000yqd.googlegroups.com...
Quote:
I have some log files that contain text and Xml ie:

....
Quote:
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? ; )


---
 
 
Page 1 of 1    
All times are GMT - 5 Hours
The time now is Sat Nov 28, 2009 5:01 am