XML : Deleting all "" Nodes in xDocument

I seem to be having trouble deleting nodes in an XDocument.

Here is me opening the file and then loading the file in an XDocument, but from here i am unsure on how to delete all the "Nodes" that are called "Time".

  using (IsolatedStorageFileStream doc = localStorage.OpenFile(xmlFile, FileMode.Open))  {      System.Xml.Linq.XDocument test = System.Xml.Linq.XDocument.Load(doc);                   }    

Here is the sample XML:

  <Shape xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">  <Latitude>51.262952</Latitude>  <Longitude>-0.596507</Longitude>  <Elevation>0</Elevation>  <AltitudeRef>Ellipsoid</AltitudeRef>  <Name>Route 2</Name>  <Description />  <Time xsi:nil="true" />  <Number xsi:nil="true" />  <Type>Route</Type>  <Extensions />  <LineColour>102</LineColour>  <LineOpacity>0.800000011920929</LineOpacity>  <LineWidth>5</LineWidth>  <ShapeType>Route</ShapeType>  <ShapeSegments>    <ShapeSegment>      <Points>        <Point>          <Latitude>51.262952</Latitude>          <Longitude>-0.596507</Longitude>          <Elevation>47.63</Elevation>          <AltitudeRef>Ellipsoid</AltitudeRef>          <Time>2016-01-15T11:58:48.0449337+00:00</Time>          <Name>WP0</Name>          <Type>Waypoint</Type>          <Description>Depart Cumberland Avenue toward Weydown Lane</Description>          <RestTicks>0</RestTicks>          <DatabaseID>-1</DatabaseID>        </Point>        <Point>          <Latitude>51.26366</Latitude>          <Longitude>-0.595391</Longitude>          <Elevation>45.71</Elevation>          <AltitudeRef>Ellipsoid</AltitudeRef>          <Time>2016-01-15T11:58:48.0469339+00:00</Time>          <Name>WP1</Name>          <Type>Waypoint</Type>          <Description />          <RestTicks>0</RestTicks>          <DatabaseID>-1</DatabaseID>        </Point>    

I want to remove all the Nodes called "Time" and then save.

No comments:

Post a Comment