473,385 Members | 1,753 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Starting to read xml part way through a file

Are any of the xml streaming classes able to start reading from an xml file
part way through?

Say you have the following xml:

<root>
<elem val = "1"/>
<elem val = "2"/> **<>**
<elem val = "3"/>
</root>

Is it possible for any of the Xml streaming classes to pick up reading the
data indicated by **<>** and continue on as normal?

Thanks
Nov 12 '05 #1
5 1193
What I really want to be able to do is create an XmlReader that I can detach
from a stream. Persist the XmlReader's state, then reattach it to the stream
at a later date and have the XmlReader advance up to where it was in the
stream instantly by doing a seek on the stream.

That's not much to ask!

I assume XmlReader is not up to the job. Bar writing my own xml reader, is
there anything out there in the .net community to achieve something similar?
"Xerox" <an**@anon.com> wrote in message
news:#h**************@tk2msftngp13.phx.gbl...
Are any of the xml streaming classes able to start reading from an xml file part way through?

Say you have the following xml:

<root>
<elem val = "1"/>
<elem val = "2"/> **<>**
<elem val = "3"/>
</root>

Is it possible for any of the Xml streaming classes to pick up reading the
data indicated by **<>** and continue on as normal?

Thanks

Nov 12 '05 #2
Xerox wrote:
What I really want to be able to do is create an XmlReader that I can detach
from a stream. Persist the XmlReader's state, then reattach it to the stream
at a later date and have the XmlReader advance up to where it was in the
stream instantly by doing a seek on the stream.


I think it should work unless you are modifying stream, why not? But
what's the point?

--
Oleg Tkachenko [XML MVP, MCP]
http://blog.tkachenko.com
Nov 12 '05 #3
Well, Xml Reader does not support that scenario unfortunately. It expects to
start from the beginning of the document.

My requirement is to be able to part process an xml file, then complete the
processing later on. This could even be after a system reboot! And the files
could be very large. Say 200mb or more. It must be stream based xml
processing, and I don't want to have to start reading from the start because
the files will be coming over the network.

I am considering developing such a facililty myself but don't fancy coding
xml parsing from scratch. Are there any helper libraries out there that
could relieve some of the burden?

Thanks

"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Xerox wrote:
What I really want to be able to do is create an XmlReader that I can detach from a stream. Persist the XmlReader's state, then reattach it to the stream at a later date and have the XmlReader advance up to where it was in the
stream instantly by doing a seek on the stream.


I think it should work unless you are modifying stream, why not? But
what's the point?

--
Oleg Tkachenko [XML MVP, MCP]
http://blog.tkachenko.com

Nov 12 '05 #4
Okay. On closer inspection it might just be able to do what I want.

There is a method on XmlTextReader called GetRemainder that returns what is
left in its buffer. If I record the current position in the underlying
stream and combine it with the buffer contents I could get somewhere.

In the mean time, any pointers welcome!

Thanks

"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message
news:#6**************@TK2MSFTNGP15.phx.gbl...
Xerox wrote:
What I really want to be able to do is create an XmlReader that I can detach from a stream. Persist the XmlReader's state, then reattach it to the stream at a later date and have the XmlReader advance up to where it was in the
stream instantly by doing a seek on the stream.


I think it should work unless you are modifying stream, why not? But
what's the point?

--
Oleg Tkachenko [XML MVP, MCP]
http://blog.tkachenko.com

Nov 12 '05 #5
Non starter. GetRemainder returns the entire remainder of the stream, not
just what is left in the buffer. It must also load the entire remainder in
to memory because when I close the underlying stream it still works. Oh
well.

"Xerox" <in**@thinkscape.com> wrote in message
news:e2**************@TK2MSFTNGP14.phx.gbl...
Okay. On closer inspection it might just be able to do what I want.

There is a method on XmlTextReader called GetRemainder that returns what is left in its buffer. If I record the current position in the underlying
stream and combine it with the buffer contents I could get somewhere.

In the mean time, any pointers welcome!

Thanks

"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message
news:#6**************@TK2MSFTNGP15.phx.gbl...
Xerox wrote:
What I really want to be able to do is create an XmlReader that I can detach from a stream. Persist the XmlReader's state, then reattach it to the stream at a later date and have the XmlReader advance up to where it was in the stream instantly by doing a seek on the stream.


I think it should work unless you are modifying stream, why not? But
what's the point?

--
Oleg Tkachenko [XML MVP, MCP]
http://blog.tkachenko.com


Nov 12 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jason Charalambides | last post by:
Hello, My question is: How do I get my application to start by double clicking on a file. I have made my application to save files with a specific extension. I associated those files to my...
6
by: chuck amadi | last post by:
Hi , Im trying to parse a specific users mailbox (testwwws) and output the body of the messages to a file ,that file will then be loaded into a PostGresql DB at some point . I have read the...
16
by: Chuck Amadi | last post by:
Sorry to bovver you again (again) here's script. I still can't see why the get_payload() doesn't produce the plain text message body of an emails in the testwwws users mailbox. As you can see I...
4
by: Kristof Despiere | last post by:
Suppose you have one domain, filled with a couple of users. What needs to be done now is I need to start a windows application from a webform by pressing a button on the webform (for example). ...
4
by: anne001 | last post by:
Hi For a class, students are going to run an experiment on line. Each time a subject runs, his/her data is appended to one giant text file. Their own data set will be just one line starting with...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
4
by: vikerneso | last post by:
I'm trying to write a program that would take a text file and searched for every word starting with a user specified letter. i.e. user inputs 'a' the program searches through the text file and...
11
by: Gustaf | last post by:
Some error handling code: catch (System.Xml.XmlException e) { Console.WriteLine("Error in " + e.SourceUri + ": " + e.Message); return; } The output:
63
by: Bill Cunningham | last post by:
I don't think I can do this without some help or hints. Here is the code I have. #include <stdio.h> #include <stdlib.h> double input(double input) { int count=0,div=0; double...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.