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

Reading / Writing XML To / From object model (without XMLDocument?

Hello,

My program is being sent a large XML file, anywhere between 500k - 1MB. Of
the entire file, I need to allow a user to view/edit approximately 5% of it.
To make matters a bit more complicated, there are occasions where the program
needs to load up around 5 instances of these documents. I'm trying to find
the most efficient and non-complicated way to do this.

My initial idea was to load the XML file into a DOM and get/set the element
values via a dom. This is trivial to do, however the problem with this is
each 500k instance of this document consumes ~3MB of memory.

I started looking into is creating an object model and populating it using
an XPathReader. Oleg Tkachenko posted a message to this group 11/24/2004
(XPath and Serialization) mentioning how to load an object using
serialization via an XML Fragment and posted a link to a GotDotNet
XPathReader workspace (below).

Using a XmlTextReader / XPathTextReader for getting the XML into the object
model seems possible. Once the user has updated all the data, how do I go
about writing the data back into the XML document? Do I use a XmlTextWriter
and output each value to the correct spot in the outgoing document?

Also, our object model will not be structured identically to the XML
document. For example, the root object ("Person") may span multiple nodes
within the XML. From my understanding, XmlTextReader/Writer are forward-only
type of objects, which would complicate serializing/deserializing the object
model.

Which approach would work the best f, sticking with the XmlDocument or
looking into object model serialization/deserialization using
XmlTextReader/Writer objects?

Thanks!

Damon Allison

GotDotNet - XPathReader
http://www.gotdotnet.com/Workspaces/...0-10351156f2eb
Nov 12 '05 #1
1 1546
Damon Allison wrote:
Using a XmlTextReader / XPathTextReader for getting the XML into the object
model seems possible. Once the user has updated all the data, how do I go
about writing the data back into the XML document? Do I use a XmlTextWriter
and output each value to the correct spot in the outgoing document?


For partial updating of big XML document you can use piped
XmlReader/XmlWiter technique, see recent Mark Fussel's explanation at
http://blogs.msdn.com/mfussell/archi...12/371546.aspx.

--
Oleg Tkachenko [XML MVP, MCP]
http://blog.tkachenko.com
Nov 12 '05 #2

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

Similar topics

3
by: awong | last post by:
Hi there, I was trying to convert the following VB6 code to VB.NET. But I can't find a corresponding System.XML object for MSXML IXMLDOMSelection. I am thinking to use System.XML XMLNodeList...
3
by: Dan | last post by:
Is there a better way to include the XML declaration than the following? XmlDeclaration dec =m_XMLDocument.CreateXmlDeclaration("1.0",string.Empty, "yes");...
1
by: Emsi | last post by:
Hello, how can I read values of child nodes with the XmlTextReader? File format: <root> <items> <item> <field1>value1</field1> <field2>value2</field2>
4
by: Oliver Sturm | last post by:
I have an XML file that contains fragments, meaning there's no root element. Node names are in my own "test" namespace. Looks like this: <test:info date="...">Content</test:info> <test:info...
1
by: Dan | last post by:
How would I write an XmlDocument to a file so that each node is properly indented and followed by a carriage return? Thanks...Dan
9
by: Xarky | last post by:
Hi, I am writing an XML file in the following way. Now I need to read again that file to retrieve data such as Name and Age. Can someone help me out. Thanks in Advance ...
6
by: Matt Hollingworth | last post by:
We have an XML file that contains text in various languages , ie English, French, German and Chinese etc. We currently have a StringWriter object that reads this in and transforms against an...
5
by: slinky | last post by:
I'm struggling with what should be a very basic .aspx/XML issue. I have an XML file. I have a textbox for a user to enter data and a button to submit the data. I don't wont the user to see the...
30
by: Cramer | last post by:
I've finally gotton board with TDD (test driven development) and wow is it effective! I went from sceptic to True Believer with my first effort. My question: According to the various books and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
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.