HTML:
<dataroot>
<AUTHOR>
<ID>0</ID>
<Surname>AMIS</Surname>
<FirstName>Martin</FirstName>
</AUTHOR>
<AUTHOR>
<ID>4</ID>
<Surname>ARMSTRONG</Surname>
<FirstName>Campbell</FirstName>
</AUTHOR>
<AUTHOR>
<ID>5</ID>
<Surname>ARNOLD</Surname>
<FirstName>Margot</FirstName>
</AUTHOR>
<AUTHOR>
<ID>374</ID>
<Surname>AAA</Surname>
<FirstName>aaa</FirstName>
</AUTHOR>
</dataroot>
My method gets passed the file name which in this case is AUTHOR so it coinsides with the elements and the ID.
When my code gets to xElement.Elements(file).All(ele => it bypasses it all
public Boolean deleteXml(String file, int id) { //file will be AUTHOR or BOOK String f = @"files\" + file + ".xml"; XElement xElement = XElement.Load(f); xElement.Elements(file).All(ele => { if (ele.Element("ID").Value.Equals(id.ToString())) { ele.Remove(); xElement.Save(f); } return true; }); return false; }
what is wrong?
thanks
Last edited by a moderator: