2010-05-18 69 views

回答

6

添加using System.Xml.XPath到你需要做到這一點的代碼文件。

然後你可以使用這樣的代碼: -

var attrib3 = someElement.XPathEvaluate("Element1/Element2/@Attribute3") as XAttribute; 
if (attrib3 != null) 
    attrib3.Value = "new value"; 
+0

今天你是我的個人英雄:D優秀的東西 – 2010-05-18 14:10:05

4

您的XElement使用System.Xml.XPath

和擴展方法XPathSelectElement

+0

也是一個偉大的答案。這只是一個恥辱,我不能主動分裂點。 – 2010-05-18 14:10:31

相關問題