How to Split an XML file into multiple XML Files

Viewed 14668

I am trying to split a XML file to multiple small xml files in C#.net and am trying to get the best possible approach to this. Any help on this will be great... Sample example on what I am trying to do...

Source XML document

<?xml version="1.0" standalone="yes"?>
<DATABASE>
  <DOC>
    <DOCID>8510188</DOCID>
    <ISSUE>2010</ISSUE>
    <CAT>Literature and Art</CAT>
    <TITLE>Test</TITLE>
    <TEXT>Test</TEXT>
  </DOC>
  <DOC>
    <DOCID>1510179</DOCID>
    <ISSUE>2012</ISSUE>
    <CAT>Miscellaneous</CAT>
    <TITLE>Test</TITLE>
    <TEXT>Test</TEXT>
  </DOC>
</DATABASE>

Should split to two xml documents as below

1)

<?xml version="1.0" standalone="yes"?>
<DATABASE>
  <DOC>
   <DOCID>8510188</DOCID>
   <ISSUE>2010</ISSUE>
   <CAT>Literature and Art</CAT>
   <TITLE>Test</TITLE>
   <TEXT>Test</TEXT>
  </DOC>
</DATABASE>

2)

<?xml version="1.0" standalone="yes"?>
<DATABASE>
  <DOC>
    <DOCID>1510179</DOCID>
    <ISSUE>2012</ISSUE>
    <CAT>Miscellaneous</CAT>
    <TITLE>Test</TITLE>
    <TEXT>Test</TEXT>
  </DOC>
</DATABASE>
1 Answers
Related