Thursday 4 October 2012

Remove elements from a XML file



private static XDocument GetFilteredData(XDocument resultXML)
{
 //Remove elements of xpath item/title
 //that doesn't contains the title value as 'genome'
 resultXML.Descendants("item").Descendants("title").Where(x => !(x.Value.ToLower().Contains("genome"))).Select(tit => tit.Parent).Remove();

 return resultXML;
}


No comments:

Post a Comment