Re: Whats an efficient way of insertring elements into an XML document



Nick Z. <pacemkr@xxxxxxxxx> wrote:
> But if the file is several megabytes, doesn't that mean that calling
> XmlDocument.Load() will load all that into memory each time you open
> the document, and then parse all of the data and build an in memory
> representation of the whole file. Thats seems incredibly inefficient in
> performance critical situation.

How often are you expecting to need to insert elements into the
document? Have you considered using a format other than XML? XML really
isn't terribly friendly when it comes to appending.

Alternatively, consider having a file which contains *multiple* XML
documents, and a class which can build them up into a single one. You
could then combine the "fragments" every so often to restore it to a
proper XML file.

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



Relevant Pages

  • Re: Sending existing XML document to a document-literal web servic
    ... So the WSDL defines a type ... I don't want to parse the existing document and load the productOrderType ... My understanding is that you can use XmlSerializer to read the XML document ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • Re: Grouping of elements?
    ... If I parse the XML into DOM, ... new element using more memory at runtime? ...
    (comp.text.xml)
  • Re: Database for C#?
    ... I want the XML file that .Net generates to have separate Nodes for each language so that we can selectively load only the language text values for the language that the user selects for the Add-in. ... That will reduce the memory and make it quicker to load. ... <XMLData> ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Saving program state in executable
    ... UML or OWL data using XML's DOM model, it takes quite a while to load ... The overhead is mostly the textprocessing and parsing of the XML models. ... 'const' record, or set of records, at compile time, and that might be ... knows it is one block of memory (assuming it doesn't contain e.g. ...
    (comp.lang.pascal.misc)
  • Re: Another idea from pick goes mainstream...
    ... technologies that comes out tends to be something that pick had for 30+ ... I can remember when UNIX folks talked about how neat the new "demand" paged ... The UNIX concept of demand paged memory was only vaguely related to the ... Then, XML came out. ...
    (comp.databases.pick)