Bibek Gautam
Bibek Gautam

Reputation: 592

Removing a node with its children in xml

I Have following XMl Format:

<kml xmlns="http://www.opengis.net/kml/2.2">
  <Document>
    <Name>TestDoc</Name>
    <Style id="Style1">
      <PolyStyle>
        <fill>0</fill>
      </PolyStyle>
    </Style>
    <Folder>
      <Name>Folder1</Name>
      <Placemark>
        <Name>Placemark1Folder1</Name>
        <LookAt>
          <longitude>-122.0839597145766</longitude>
          <latitude>37.42222904525232</latitude>
        </LookAt>
      </Placemark>
      <Placemark>
        <Name>Placemark2Folder1</Name>
        <LookAt>
          <longitude>-101.083959</longitude>
          <latitude>26.422</latitude>
        </LookAt>
      </Placemark>
    </Folder>
    <Folder>
      <Name>Folder2</Name>
      <Placemark>
        <Name>Placemark1Folder2</Name>
        <LookAt>
          <longitude>-96.566556</longitude>
          <latitude>14.422</latitude>
        </LookAt>
      </Placemark>
    </Folder>
  </Document>
</kml>

I want to remove all nodes inside nodes with all its( node ) childrens in vb.net ..Hence Output Xml Should look like :::

<kml xmlns="http://www.opengis.net/kml/2.2">
  <Document>
    <Name>TestDoc</Name>
    <Style id="Style1">
      <PolyStyle>
        <fill>0</fill>
      </PolyStyle>
    </Style>

  </Document>
</kml> ..

How to accomplish this...Thanx in advance..

Upvotes: 2

Views: 1853

Answers (1)

&#248;mi
&#248;mi

Reputation: 521

nod.ParentNode.ParentNode.RemoveChild(nod.ParentNode)

or u can try

this

Upvotes: 1

Related Questions