求解释!“object”不包含“ReplaceWith”的定义,并且找不到可接受类型为“object”的第一个参数的扩展方法“ReplaceWith”(是否缺少
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class _7_02 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void TextBox3_TextChanged(object sender, EventArgs e)
{
}
protected void btnEdit_Click(object sender, EventArgs e)
{
string strXElement= texElement.Text.Trim().ToString() ; //得到原节点名
string strValue = texValue.Text.Trim().ToString(); //得到原节点值
string strNewXElement = texNewElement.Text.Trim().ToString(); //得到新节点名
string strNewValue = texNewValue.Text.Trim().ToString(); //得到新节点值
XElement xel = XElement.Load(Server.MapPath("Product.xml")); //加载xml文件
//原节点,查询所有符合条件的节点
var item=from x in xel.Descendants("Pruduct")
where (string)xel.Element(strXElement).Value==strValue
select x;
// 遍历每一个查询得到的节点
foreach(var i in item)
{
//修改节点
Element(strXElement).ReplaceWith(new XElement(strNewXElement,strNewValue));
}
xel.Save(Server.MapPath("newEdit.xml"));
}
错误提示:“object”不包含“ReplaceWith”的定义,并且找不到可接受类型为“object”的第一个参数的扩展方法“ReplaceWith”(是否缺少 using 指令或程序集引用?)