顯示具有 Xml 標籤的文章。 顯示所有文章
顯示具有 Xml 標籤的文章。 顯示所有文章

2012年5月21日 星期一

Linq Xml 寫入

有讀取 當然就有寫入
所以記錄一下寫入
XmlString = XElement.Load(xmlFile);
XElement  xmlLinq = (from a in XmlString.Elements(Elements1)
                          select a).Single();
        xmlLinq.Value = value;
        XmlString.Save(XmlFile);


2011年1月25日 星期二

Linq Xml 簡單搜尋

Xml搜尋
最主要就是 Elements 是欄位名稱 ex: <Element>
Attributes 是欄位設定值  ex: <Element Attribute='123'>
Value 是裡面的值 ex: <Element>Value</Element>

XElement XmlString;
var xmlLinq = (from a in XmlString.Elements("SetElement").Attributes("id")
select a.Value).ToList();