title: Splitting Xml Document according to node
body: <p>My xml document looks like .. (its actually a kml file for google map..)</p>
  
  <pre><code> &lt;kml xmlns="http://www.opengis.net/kml/2.2"&gt;
    &lt;Document&gt;
      &lt;Folder&gt;
        &lt;Name&gt;Folder1&lt;/Name&gt;
        &lt;Placemark&gt;
          &lt;Name&gt;Placemark1Folder1&lt;/Name&gt;
          &lt;LookAt&gt;
            &lt;longitude&gt;-122.0839597145766&lt;/longitude&gt;
            &lt;latitude&gt;37.42222904525232&lt;/latitude&gt;
          &lt;/LookAt&gt;
        &lt;/Placemark&gt;
        &lt;Placemark&gt;
          &lt;Name&gt;Placemark2Folder1&lt;/Name&gt;
          &lt;LookAt&gt;
            &lt;longitude&gt;-101.083959&lt;/longitude&gt;
            &lt;latitude&gt;26.422&lt;/latitude&gt;
          &lt;/LookAt&gt;
        &lt;/Placemark&gt;
      &lt;/Folder&gt;
      &lt;Folder&gt;
        &lt;Name&gt;Folder2&lt;/Name&gt;
        &lt;Placemark&gt;
          &lt;Name&gt;Placemark1Folder2&lt;/Name&gt;
          &lt;LookAt&gt;
            &lt;longitude&gt;-96.566556&lt;/longitude&gt;
            &lt;latitude&gt;14.422&lt;/latitude&gt;
          &lt;/LookAt&gt;
        &lt;/Placemark&gt;
      &lt;/Folder&gt;
    &lt;/Document&gt;
  &lt;/kml&gt;
  </code></pre>
  
  <p>According to each Placemark for each folder node i will like to make a separate xml file like</p>
  
  <p><strong>1st XML:</strong></p>
  
  <pre><code>&lt;kml xmlns="http://www.opengis.net/kml/2.2"&gt;
    &lt;Document&gt;
      &lt;Folder&gt;
        &lt;Name&gt;Folder1&lt;/Name&gt;
        &lt;Placemark&gt;
          &lt;Name&gt;Placemark1Folder1&lt;/Name&gt;
          &lt;LookAt&gt;
            &lt;longitude&gt;-122.0839597145766&lt;/longitude&gt;
            &lt;latitude&gt;37.42222904525232&lt;/latitude&gt;
          &lt;/LookAt&gt;
        &lt;/Placemark&gt;
      &lt;/Folder&gt;
    &lt;/Document&gt;
  &lt;/kml&gt;
  </code></pre>
  
  <p><strong>2nd xml</strong></p>
  
  <pre><code>&lt;kml xmlns="http://www.opengis.net/kml/2.2"&gt;
    &lt;Document&gt;
      &lt;Folder&gt;
        &lt;Name&gt;Folder1&lt;/Name&gt;
        &lt;Placemark&gt;
          &lt;Name&gt;Placemark2Folder1&lt;/Name&gt;
          &lt;LookAt&gt;
            &lt;longitude&gt;-101.083959&lt;/longitude&gt;
            &lt;latitude&gt;26.422&lt;/latitude&gt;
          &lt;/LookAt&gt;
        &lt;/Placemark&gt;
      &lt;/Folder&gt;
    &lt;/Document&gt;
  &lt;/kml&gt;
  </code></pre>
  
  <p><strong>3rd xml</strong></p>
  
  <pre><code>&lt;kml xmlns="http://www.opengis.net/kml/2.2"&gt;
    &lt;Document&gt;
      &lt;Folder&gt;
        &lt;Name&gt;Folder2&lt;/Name&gt;
        &lt;Placemark&gt;
          &lt;Name&gt;Placemark1Folder2&lt;/Name&gt;
          &lt;LookAt&gt;
            &lt;longitude&gt;-96.566556&lt;/longitude&gt;
            &lt;latitude&gt;14.422&lt;/latitude&gt;
          &lt;/LookAt&gt;
        &lt;/Placemark&gt;
      &lt;/Folder&gt;
    &lt;/Document&gt;
  &lt;/kml&gt;
  </code></pre>
  
  <p>..i am very beginner in xml ..help please</p>