473,507 Members | 2,379 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.Length;

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.Length;

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 1034

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

Similar topics

5
3599
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. ...
6
7343
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...
1
17100
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...
3
3764
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>"); ...
1
4615
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...
2
6010
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...
2
6186
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 ...
7
4878
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: ...
4
13627
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
7223
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
7111
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
7319
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,...
0
7376
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...
0
7485
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...
1
5042
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...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1542
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 ...
0
412
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...

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.