473,385 Members | 2,044 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,385 software developers and data experts.

XmlDocument.WriteTo method truncating at 2048 characters

I am attempting to write an XmlDocument to file, but for some reason it will
only write 2048 characters of the document even though when I stop it in the
debugger ALL of the document is there.

Code snippet is as follows:

XmlDocument xml = new XmlDocument();
xml.LoadXml(Encoding.UTF8.GetString(btResponse));
XmlTextWriter w = new XmlTextWriter("..\\..\\..\\xml\\Test.xml", null);
xml.WriteTo(w); // will not write anything after 2048 bytes

Any suggestions?
Jul 28 '06 #1
2 2788
William <nf*@nospam.comwrote:
I am attempting to write an XmlDocument to file, but for some reason it will
only write 2048 characters of the document even though when I stop it in the
debugger ALL of the document is there.

Code snippet is as follows:

XmlDocument xml = new XmlDocument();
xml.LoadXml(Encoding.UTF8.GetString(btResponse));
XmlTextWriter w = new XmlTextWriter("..\\..\\..\\xml\\Test.xml", null);
xml.WriteTo(w); // will not write anything after 2048 bytes

Any suggestions?
Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

My guess is that you're not disposing it, so the underlying stream
isn't getting closed.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jul 28 '06 #2
Not closing was the problem... thx.

"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP************************@msnews.microsoft.c om...
William <nf*@nospam.comwrote:
>I am attempting to write an XmlDocument to file, but for some reason it
will
only write 2048 characters of the document even though when I stop it in
the
debugger ALL of the document is there.

Code snippet is as follows:

XmlDocument xml = new XmlDocument();
xml.LoadXml(Encoding.UTF8.GetString(btResponse) );
XmlTextWriter w = new XmlTextWriter("..\\..\\..\\xml\\Test.xml", null);
xml.WriteTo(w); // will not write anything after 2048 bytes

Any suggestions?

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

My guess is that you're not disposing it, so the underlying stream
isn't getting closed.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Jul 29 '06 #3

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

Similar topics

3
by: Zoury | last post by:
Hi folks ! :O) I'm trying to show a PDF in ASP.NET but I can't get to work properly. here's a portion of my code : '** Dim ms As MemoryStream =...
5
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. ...
13
by: Matthew Wieder | last post by:
In my C# application, I have class which has method that opens an XML document, modifies it and saves it out. I run that method for several different XML documents. What I've found is that the...
2
by: David Withnall | last post by:
Okay I am using an XMLDocument object to process several thousands of lodgements (from a database) I am trying to output it from an XML Document to a file using the XmlDocument.WriteTo() method...
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");...
2
by: Charles.Deisler | last post by:
I'm reading a xmldocument in from the file system and using xmldocument.writeto(xmltextwriter) to stream the xml data to the response.outputstream. From what i've read, reading an xmldocument is...
1
by: Robin Hay | last post by:
I have created a class which inherits from XmlDocument. It works as I expected. If I use Visual Studio, and type a <carriage return> after "inherits XmlDocument", VS adds three method overrides....
5
by: Andy Fish | last post by:
Hi, I am using XmlDocument.WriteTo() and I find that the xml declaration is not included. at the moment I am doing this: XmlTextWriter xw = new XmlTextWriter(...); xw.WriteStartDocument();...
5
by: Gustaf | last post by:
I've been trying to update my code to the new XslCompiledTransform class without success. The following method takes an XML and XSL file, and returns an XmlDocument object. Can anyone figure out...
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:
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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...

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.