random access to elements of a disk-based XML file

B

Bruce

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
 
J

Jon Skeet [C# MVP]

Bruce said:
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?
 
B

Bruce

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
 
P

Peter Huang [MSFT]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top