Connecting Tech Pros Worldwide Forums | Help | Site Map

split massive xml file

Jeremy
Guest
 
Posts: n/a
#1: Jun 18 '07
I have an xml file (sample below) that is massive. hundreds of megs maybe
thousands. I need to split it up into multiple files so each file gets a
copy of the header element and sub elements and 1 detail element. There
will be 1 file created for each detail element. Any tips how to do this?
Can I get away with not loading the whole file into memory at one time?

sample:

<header>
</header>
<details>
<detail />
<detail />
<details />



John Saunders [MVP]
Guest
 
Posts: n/a
#2: Jun 18 '07

re: split massive xml file


"Jeremy" <nospam@please.comwrote in message
news:%23oCR4hcsHHA.1208@TK2MSFTNGP03.phx.gbl...
Quote:
>I have an xml file (sample below) that is massive. hundreds of megs maybe
>thousands. I need to split it up into multiple files so each file gets a
>copy of the header element and sub elements and 1 detail element. There
>will be 1 file created for each detail element. Any tips how to do this?
>Can I get away with not loading the whole file into memory at one time?
>
sample:
>
<header>
</header>
<details>
<detail />
<detail />
<details />
Your file doesn't actually look like this, right? This file has two
top-level elements, and only one is permitted.

You should look into using an XmlReader to read the file. An XmlWriter can
be used to write to the multiple output files.
--
John Saunders [MVP]


Closed Thread


Similar .NET Framework bytes