473,386 Members | 1,860 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,386 software developers and data experts.

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 2996
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Keith Griffiths | last post by:
I'm trying to do a search under a set criteria followed by a selection of random entries meeting this criteria. But I don't seem to be able to achieve this. The idea being to search on say...
11
by: Dr John Stockton | last post by:
Q1 : Given an array such as might have been generated by var A = is there a highly effective way of reducing it to - i.e. removing the undefineds and shifting the rest down? ...
1
by: jprunier | last post by:
Hi I isolated this code which gives me odd results and I am not sure to understand why. Basically I declared "positions" as a map that I am using to store pairs of integers. The key used for the...
2
by: vsgdp | last post by:
From what I learned, if you want to do random element insertions and deletions you should use a list. But, with std::vector, if the order of the elements does not matter, couldn't you efficiently...
3
by: Phil Sherman | last post by:
What is the relationship between the snapshot elements: Log pages written Number write log IOs Number partial page log IOs There doesn't appear to be any information in my PDF System monitor...
5
by: jar13861 | last post by:
I'm confused on how to write a random array that will only generate 9 different numbers from 1-9. Here is what I have, but its only writing one number.... holder = new Array ( 9 ); var flag =...
13
by: porterboy76 | last post by:
If you only use a 32 bit seed for a random number generator, does that mean you can only ever produce a maximum of 2^32 (approx 4 billion) different sequences? What about the Mersenne Twister,...
9
by: Tuxedo | last post by:
I'd like to reorganize the third, fourth, fifth and sixth, as well as any elements thereafter in an array in random order: var a = new...
15
by: caca | last post by:
Hello, This is a question for the best method (in terms of performance only) to choose a random element from a list among those that satisfy a certain property. This is the setting: I need to...
36
by: Peter Olcott | last post by:
So far the only way that I found to do this was by making a single global instance of the container class and providing access to the contained class, through this single global instance. Are...
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.