473,799 Members | 2,786 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1572
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
4882
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 object and GetElementsByTagName method to find the "selection". Any suggestion/comment? Thanks in advance.
3
9055
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"); m_XMLDocument.InsertBefore((XmlNode)dec, (XmlNode)m_XMLDocument.DocumentElement); XmlTextWriter writer = new XmlTextWriter(m_FileName,Encoding.Default); writer.WriteRaw(m_XMLDocument.OuterXml); writer.Flush();
1
16440
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
1571
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 date="...">Other content</test:info> .... I have some .net 1.1 code that reads the nodes from the file one by one: FileStream stream = new FileStream(@"file.xml", FileMode.Open);
1
2927
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
1994
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 /*********************************/ static void writeXML() {
6
2491
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 XslTransform object. the problem arises when we encounter Chinese characters; these characters just come out as garbage in the internet explorer browser. Setting the charset type on the .aspx page, in the web.config and in the ..xsl file to be...
5
1516
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 other records on the screen. I'm using Visual Web Developer Express 2005, vb.NET) I've tried several different strategies from books and online examples, but I can't seem to get anywhere. I'm guessing I need to Dim a DataSet (even though I'm adding...
30
2707
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 articles I have read about TDD, a good unit test does not rely on the database or other such external/environmental conditions. More generally, a good unit test is atomic and makes as few assumptions about its runtime environment as possible. But...
0
9687
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10029
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9077
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7567
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4144
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.