MY XML FILE STRUCTURE
<items>
<item>
<itemID>1</itemID>
<isGadget>True</isGadget>
<name>Star Wars Figures</name>
<text1>LukeSkywalker</text1>
</item>
</items>
TO READ DATA FROM XML BY ITEMID
XDocument xmlDoc = XDocument.Load(HttpContext.Current.Server.MapPath("data.xml"));
var items = from item in xmlDoc.Descendants("item")
where item.Element("itemID").Value == itemID
select new
{
itemID = item.Element("itemID").Value,
isGadget = bool.Parse(item.Element("isGadget").Value),
name = item.Element("name").Value,
text1 = item.Element("text1").Value,
}
foreach (var item in items)
{
....
}
How to update XML data by itemID? Thanks!
See Question&Answers more detail:os