473,664 Members | 3,022 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Size of an XMLDocument without using OuterXml

2 New Member
Hi

Is it possible to find out the output size of an XmlDocument object?
I mean, a good-enough approach is this:
XmlDocument doc = new XmlDocument();
// load data in doc
int length = doc.OuterXml.Le ngth;

1.Advantages:
1.1. It's an approximate value, but the approximation is very good, so I put this as an advantage
1.2. A single line of code to get the length:
int length = doc.OuterXml.Le ngth;

2. Disadvantages:
2.1. OuterXml property is a calculated value. This means:
2.1.1. Extra computation
2.1.2. Extra memory

When dealing with small xml's, the solution is relatively ok.
But when dealing with large (huge) xml's, this solution is not a solution anymore. This is because OuterXml in fact returns a string, even if I don't need its data, but its length.
It's almost obvious to me that we couldn't eliminate the factor 2.1.1 from disadvantages list, but it seems to me the factor 2.1.2 is likely to be improved.
So, I'm searching a way to compute the length of this string by generating it in chunks. That is, I want to "reinvent" the OuterXml, but in several linked steps.
Put it in another way, I want to "stream" this property.

Accessing OuterXml in a stream-like fashion could also help in (de)crypting / (de)compressing it.

Any idea?
Thanks.
Sep 19 '07 #1
0 1041

Sign in to post your reply or Sign up for a free account.

Similar topics

5
3610
by: Jack Fox | last post by:
I'm still new to Xml, but finding it very useful. Conceptually what I want to do is compress an XmlDocument, save it to SQL Server as image data, read it back and restore it to an XmlDocument. I'm a bit bewildered by the choices available (XmlSerialization, XmlWriter, Xml on SQL Server) and do not have any experience with them, so I was wondering what is the best way to do this?
6
7351
by: Yechezkal Gutfreund | last post by:
I have been using the following code (successfully) to read Xml formated text packets from a TCP stream. The output from the server stream consists of a sequence of well formed Xml documents written to the output stream. We are willing to pay $ to any expert (e.g. MVP) consultant who has to time to help us track down this problem. (we will discuss rates if you can prove your expertise, and problem solving approach).
1
17125
by: Martin Honnen | last post by:
With both .NET 1.0 and 1.1 I have found the following strange behaviour where System.Xml.XmlDocument.LoadXml doesn't throw an error when parsing a text node with a character reference to an invalid characters like . Using the CreateTextNode method I create a text node containing "\u0001a" (C# string literal notation). As far as I understand the DOM allows that and an implementation is not required to throw an error. When OuterXml is...
3
3767
by: todd | last post by:
Simply trying to load xml into a DOM without the dom converting my escape sequence. **code snippet** XmlDocument xmlDoc = new XmlDocument() ; xmlDoc.LoadXml("<x>hello world</x>"); **results**
1
4628
by: Adam Smith | last post by:
When you do this: public void someMethod(Xmldocument xml) { XmlDocument localxml = new XmlDocument(); localxml.LoadXml(xml.OuterXml); } Are you getting all the data in localxml? I want to send binary data such as a Microsoft word doc embedded in my xml document. I have
2
6031
by: Graham Pengelly | last post by:
Hi I am trying to transform on System.Xml.XmlDocument into another using XslTransform without writing the object out to a file. I am guessing it should work something like this... public XmlDocument TransformXmlDoc(XmlDocument docToTransform, string xsltFilePath) { //load the xslt
2
6202
by: Dave | last post by:
Hi, Is there an easier way to pull a subset of nodes from one XmlDocument to another? I have the code below but would like to know if there is a more streamlined method. Thanks, Dave XmlNodeList nodeList = doc1.SelectNodes("//row"); foreach (XmlNode nodeCode in nodeList) { sb.Append(nodeCode.OuterXml);
7
4895
by: SQLScott | last post by:
I have a Web Service in which I am trying to pass an XMLDocument as a parameter to one of the methods. I would like to use the XMLTextReader to read the XML but I am getting the following error: Value of type System.xml.xmldocument cannot be converted to System.IO.textreader. I would think this is possible to do. Code snippet is below:
4
13669
by: Saurabh Sharma | last post by:
Hi I am making a XmlDocument . How can i check the Size of the file size of XmlDocument when i will save it to the disk. Regards Saurabh Sharma
0
8437
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
8861
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8778
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
8636
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
7375
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...
0
4185
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
2764
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
2003
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1759
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.