XML替换节点问题 高手请进
数据库中有一个XML字段 存的值是<Question>
<QuestionType Code="1" Type="单选题" />
<QuestionField>
<Field Name="Q_Title" />
<Field Name="Q_Type" />
<Field Name="Q_DropDownBox" />
<Field Name="Q_PictureRotation" />
<Field Name="Q_Rotation"/>
</QuestionField>
</Question>
要将换节点
<QuestionField>
<Field Name="Q_Title" />
<Field Name="Q_Type" />
<Field Name="Q_DropDownBox" />
<Field Name="Q_PictureRotation" />
<Field Name="Q_Rotation"/>
</QuestionField>
替换为
<QuestionField>
<Field Name="T_Title" />
<Field Name="T_Type" />
</QuestionField>
怎么写sql? --------------------编程问答--------------------
--------------------编程问答--------------------
XmlDocument doc = new XmlDocument();
doc.LoadXml(@"
<Question>
<QuestionType Code=""1"" Type=""单选题"" />
<QuestionField>
<Field Name=""Q_Title"" />
<Field Name=""Q_Type"" />
<Field Name=""Q_DropDownBox"" />
<Field Name=""Q_PictureRotation"" />
<Field Name=""Q_Rotation""/>
</QuestionField>
</Question>");
doc.SelectSingleNode(@"//Field[@Name=""Q_Title""]").Attributes["Name"].InnerText = "T_Title";
doc.SelectSingleNode(@"//Field[@Name=""Q_Type""]").Attributes["Name"].InnerText = "T_Type";
doc.FirstChild.LastChild.RemoveChild(doc.SelectSingleNode(@"//Field[@Name=""Q_DropDownBox""]"));
doc.FirstChild.LastChild.RemoveChild(doc.SelectSingleNode(@"//Field[@Name=""Q_PictureRotation""]"));
doc.FirstChild.LastChild.RemoveChild(doc.SelectSingleNode(@"//Field[@Name=""Q_Rotation""]"));
Console.Write(doc.InnerXml);
<Question>
<QuestionType Code="1" Type="单选题" />
<QuestionField>
<Field Name="T_Title" />
<Field Name="T_Type" />
</QuestionField>
</Question>
--------------------编程问答-------------------- update tb set xml="new 值" where id=@id
补充:.NET技术 , ASP.NET