|
ms
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Regarding splitting Large xml files to smaller xm filesHi,
I am trying to split large xml files to smaller xml files using c#.net. can you please provide any sample code for this? I have to split the file if the size is more than 10 MB. Also, xml files after splitting should be valid xml. i am new to Csharp? Thanks for your help Nikila Check out the Xml namespace in .NET.
Particularly the XmlDocument class. I would load your XML doc into one of those, and then use the nodes collection to move elements to new XmlDocuments. Not sure how you can base it on size though. I guess you could write a recursive function that checks all child nodes and their innerxml properties, counting the chars. nikila wrote: Show quoteHide quote > Hi, > > I am trying to split large xml files to smaller xml files using c#.net. can > you please provide any sample code for this? I have to split the file if the > size is more than 10 MB. > > Also, xml files after splitting should be valid xml. i am new to Csharp? > > > Thanks for your help > > Nikila Nikila,
What I would do is read through the child elements of the document root. As you read through them, I would write them to another file. After you write each element, flush the writer so that the file is written to, then check it's length. If you find that the file is too long, then you can trim the file down (I would store the length of the file before that point). You have to make sure that you write the document element for each file that you write out as well, so after you write the fragments to one file, make sure you write the closing document element, and then open a new file with a new document element. Hope this helps. -- Show quoteHide quote- Nicholas Paldino [.NET/C# MVP] - mvp@spam.guard.caspershouse.com "nikila" <niki***@yahoo.com> wrote in message news:OEvZQAhpGHA.516@TK2MSFTNGP05.phx.gbl... > Hi, > > I am trying to split large xml files to smaller xml files using c#.net. > can you please provide any sample code for this? I have to split the file > if the size is more than 10 MB. > > Also, xml files after splitting should be valid xml. i am new to Csharp? > > > Thanks for your help > > Nikila > Hi,
Thank you for your reply. But can anybody provide me some sample code for this. Thanks, Neelima Show quoteHide quote "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard.caspershouse.com> wrote in message news:efbArDjpGHA.4988@TK2MSFTNGP04.phx.gbl... > Nikila, > > What I would do is read through the child elements of the document > root. As you read through them, I would write them to another file. After > you write each element, flush the writer so that the file is written to, > then check it's length. If you find that the file is too long, then you > can trim the file down (I would store the length of the file before that > point). > > You have to make sure that you write the document element for each file > that you write out as well, so after you write the fragments to one file, > make sure you write the closing document element, and then open a new file > with a new document element. > > Hope this helps. > > > -- > - Nicholas Paldino [.NET/C# MVP] > - mvp@spam.guard.caspershouse.com > > > "nikila" <niki***@yahoo.com> wrote in message > news:OEvZQAhpGHA.516@TK2MSFTNGP05.phx.gbl... >> Hi, >> >> I am trying to split large xml files to smaller xml files using c#.net. >> can you please provide any sample code for this? I have to split the file >> if the size is more than 10 MB. >> >> Also, xml files after splitting should be valid xml. i am new to Csharp? >> >> >> Thanks for your help >> >> Nikila >> > >
Strong name signing question!
WndProc Message Forwarding Trying to launch Trillian through C# program GetType and Interfaces System.Diagnostics.Process / .BAT file / always returns exit code 0 Behavior of Monitor.Wait and exception No process is associated with this object error (New) DataGridView Question getting network computer name WritePrinter |
|||||||||||||||||||||||