Suppose you want to compare with the DateTime variable inputDate .
// I have formatted yor XML and structured it. "root" is the the parent node. Elements are the child elements of root consisting of timestamp tag. string xmlInput = @" <root> <element> <timestamp time='2016-09-16T13:45:30'> </timestamp> </element> <element> <timestamp time='2016-10-16T13:45:30'> </timestamp> </element> </root>"; XDocument xdoc = XDocument.Parse(xmlInput); xdoc.Descendants("root").Elements("element"). Where(x => DateTime.Compare(DateTime.Parse(x.Element("timestamp").Attribute("time").Value,null, DateTimeStyles.RoundtripKind).Date, inputDate.Date) ==0). ToList().ForEach(x => x.Remove());
I matched the xml date of the timestamp for each element with inputDate to equal only the date, not the time. You can choose any condition.
Note: you need to access using System.Globalization;
using System.Globalization; using System.Xml.Linq; using System.Xml; using System.Linq;
source share