469,602 Members | 1,765 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,602 developers. It's quick & easy.

random access to elements of a disk-based XML file


I am building a WinForms app that uses Web Services access to a server for
most of its data input/output, but I also need to persist some of its data
to the local disk (basically as a cache of some of the Web Services data) in
XML format.

Since the size of the XML local store could be rather large, I'd prefer to
have a random access mechanism for reading and writing to it. It seems that
XMLReader /XMLWriter are sequentially fast, but have no facility for random
access. XMLDocument can do random access, but only via a complete in-memory
copy of the data that I hold on disk. Correct?

Is there a truly random access alternative, for reading/writing individual
elements (or branches) of an XML file?

Thanks,

-- Bruce
Mar 15 '06 #1
3 2743
Bruce <co*********@newsgroup.nospam> wrote:
I am building a WinForms app that uses Web Services access to a server for
most of its data input/output, but I also need to persist some of its data
to the local disk (basically as a cache of some of the Web Services data) in
XML format.

Since the size of the XML local store could be rather large, I'd prefer to
have a random access mechanism for reading and writing to it. It seems that
XMLReader /XMLWriter are sequentially fast, but have no facility for random
access. XMLDocument can do random access, but only via a complete in-memory
copy of the data that I hold on disk. Correct?
Yes.
Is there a truly random access alternative, for reading/writing individual
elements (or branches) of an XML file?


No. You'd need to keep some kind of index of where each element
started, then seek to that location to read it. Unfortunately, with
buffering etc, keeping that index isn't terribly easy.

Have you considered transforming your data into something less
freeform, like a fixed length record format?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Mar 15 '06 #2
Jon ,

Thanks for the answers.

Yes, I may have to consider a non_XML, fixed-length alternative. But first,
I'll probably try using the XMLDocument approach and see how "costly" it is
to read/write the entire file on each access.

Thanks,
Bruce

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Bruce <co*********@newsgroup.nospam> wrote:
I am building a WinForms app that uses Web Services access to a server
for
most of its data input/output, but I also need to persist some of its
data
to the local disk (basically as a cache of some of the Web Services data)
in
XML format.

Since the size of the XML local store could be rather large, I'd prefer
to
have a random access mechanism for reading and writing to it. It seems
that
XMLReader /XMLWriter are sequentially fast, but have no facility for
random
access. XMLDocument can do random access, but only via a complete
in-memory
copy of the data that I hold on disk. Correct?


Yes.
Is there a truly random access alternative, for reading/writing
individual
elements (or branches) of an XML file?


No. You'd need to keep some kind of index of where each element
started, then seek to that location to read it. Unfortunately, with
buffering etc, keeping that index isn't terribly easy.

Have you considered transforming your data into something less
freeform, like a fixed length record format?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Mar 15 '06 #3
Hi Bruce,

Did Jon's suggestion help you?
If you still have any concern, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 20 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Keith Griffiths | last post: by
11 posts views Thread by Dr John Stockton | last post: by
2 posts views Thread by vsgdp | last post: by
3 posts views Thread by Phil Sherman | last post: by
5 posts views Thread by jar13861 | last post: by
13 posts views Thread by porterboy76 | last post: by
15 posts views Thread by caca | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.