海的朋友,我需要与节点属性更新XML文件 我的XML结构如何更新使用LINQ XML节点
<BankName BankName="jinesh" TemplateModel="sam">
<ChqBasics>
<ChqL>30</ChqL>
<ChqW>50</ChqW>
<ChqImgPath>hai</ChqImgPath>
</ChqBasics>
<XandYPosition>
<column Name="ChqDate" X="10" Y="10" />
<column Name="CPayAgainst" X="10" Y="10" />
<column Name="ChqAmtDgt" X="10" Y="10" />
<column Name="ChqAmtWrds" X="10" Y="10" />
</XandYPosition>
我需要更新的XandYPosition节点元素所以我为此创建了一个功能,但我无法完成此操作。请帮助我实现此目的。
public static void updatenode(string bankname, string templatemodel,string field,string x,string y)
{
XDocument doc = XDocument.Load("newtest.xml");
var updatenode = doc
.Descendants("BankName")
.Where(item => item.Attribute("BankName").Value == bankname && item.Attribute("TemplateModel").Value == templatemodel)
.Select(XandYPosition => XandYPosition.Descendants("XandYPosition").Descendants());
}
函数调用会是这样
BasicClass.updatenode(comboBox1.Text, comboBox2.Text, "ChqDate", "1000", "2000");
请帮助使代码完整
UPADTE: 我怎样才能更新BANKNAME = “Jinesh” 与 “XYZ”
你想在这个XML文件以更新什么? – Vishal 2014-10-31 18:03:56