Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Edit very large xml files

Tags:

c#

xml

I would like to create a text box which loads xml files and let users edit them. However, I cannot use XmlDocument to load since the files can be very large. I am looking for options to stream/load the xml document in chunks so that I do not get out of memory errors -- at the same time, performance is important too. Could you let me know what would be good options?

like image 227
Matt Avatar asked May 20 '10 12:05

Matt


2 Answers

Try Scintilla.NET, it is miles better than a TextBox!

http://scintillanet.codeplex.com/

Loading the document is easy:

using (TextReader reader = new StreamReader(myFilePath, Encoding.UTF8))
{
    scintillaDocument.Text = reader.ReadToEnd();
}

Or:

scintillaDocument.Text = File.ReadAllText(myFilePath);
like image 77
code4life Avatar answered Sep 23 '22 15:09

code4life


Why bother with reading the xml into an xmldocument at all if all you're doing is pushing it into a textbox?

How big are you talking about here? Have you tried streaming it into a textbox yet?

sometextarea.Text = System.IO.File.ReadAllText(Server.MapPath("somexml.xml"));

Now, saving it back to the filesystem is a different story, especially if you want it to be 1. Valid xml and 2. Valid against a schema.

like image 31
ScottE Avatar answered Sep 23 '22 15:09

ScottE