我有这个xml的游戏列表 所有游戏都有单词和图片
<root>
<game GameID="122" GameName="fer" IdCARDS="5">
<CARD id="1" pic="~/pic/119.jpg" word="11" />
<CARD id="3" pic="~/pic/121.jpg" word="22" />
<CARD id="4" pic="~/pic/122.jpg" word="33" />
</game>
</root>
我可以更改卡的顺序并删除它们:
protected void DownButton_Click(object sender, ImageClickEventArgs e)
{
XmlDocument Document = XmlDataSource1.GetXmlDocument();
string theGAMEId = Label2.Text;
string cardID = (string)Session["ID2"];
string cardIDAbove = Convert.ToString(Convert.ToInt16(cardID) + 1);
string ThePicSource = Convert.ToString(Document.SelectSingleNode("//game[@GameID='" + theGAMEId + "']/CARD[@id='" + cardID + "']/@pic").InnerXml);
string TheWordSource = Convert.ToString(Document.SelectSingleNode("//game[@GameID='" + theGAMEId + "']/CARD[@id='" + cardID + "']/@word").InnerXml);
string ThePicAbove = Convert.ToString(Document.SelectSingleNode("//game[@GameID='" + theGAMEId + "']/CARD[@id='" + cardIDAbove + "']/@pic").InnerXml);
string TheWordAbove = Convert.ToString(Document.SelectSingleNode("//game[@GameID='" + theGAMEId + "']/CARD[@id='" + cardIDAbove + "']/@word").InnerXml);
Document.SelectSingleNode("//game[@GameID='" + theGAMEId + "']/CARD[@id='" + cardID + "']/@pic").InnerXml = ThePicAbove;
Document.SelectSingleNode("//game[@GameID='" + theGAMEId + "']/CARD[@id='" + cardID + "']/@word").InnerXml = TheWordAbove;
Document.SelectSingleNode("//game[@GameID='" + theGAMEId + "']/CARD[@id='" + cardIDAbove + "']/@pic").InnerXml = ThePicSource;
Document.SelectSingleNode("//game[@GameID='" + theGAMEId + "']/CARD[@id='" + cardIDAbove + "']/@word").InnerXml = TheWordSource;
XmlDataSource1.Save();
GridView1.EditIndex = -1;
GridView1.DataBind();
Session["ID2"] = cardIDAbove;
}
}
当我想删除后想要改变位置时出现问题(然后我没有ID跟随)
那我如何选择下一个节点和XML格式的前节点?