protected void Button1_Click(object sender, EventArgs e)
{
XmlNode node= xdoc.DocumentElement.SelectSingleNode("book[name='"+this.DropDownList1.Text+"']");
#region 方法一
foreach (XmlNode item in node.ChildNodes)
{
if(item.LocalName=="author")
{
this.TextBox1.Text = item.InnerText;
}
if (item.LocalName == "publisher")
{
this.TextBox2.Text = item.InnerText;
}
if (item.LocalName == "date")
{
this.TextBox3.Text = item.InnerText;
}
if (item.LocalName == "isbn")
{
this.TextBox4.Text = item.InnerText;
}
if (item.LocalName == "price")
{
this.TextBox5.Text = item.InnerText;
}
}
#endregion
#region 方法二
TextBox1.Text = node.SelectSingleNode("author").InnerText;
TextBox2.Text = node.SelectSingleNode("publisher").InnerText;
TextBox3.Text = node.SelectSingleNode("date").InnerText;
TextBox4.Text = node.SelectSingleNode("isbn").InnerText;
TextBox5.Text = node.SelectSingleNode("price").InnerText;
#endregion
}
{
XmlNode node= xdoc.DocumentElement.SelectSingleNode("book[name='"+this.DropDownList1.Text+"']");
#region 方法一
foreach (XmlNode item in node.ChildNodes)
{
if(item.LocalName=="author")
{
this.TextBox1.Text = item.InnerText;
}
if (item.LocalName == "publisher")
{
this.TextBox2.Text = item.InnerText;
}
if (item.LocalName == "date")
{
this.TextBox3.Text = item.InnerText;
}
if (item.LocalName == "isbn")
{
this.TextBox4.Text = item.InnerText;
}
if (item.LocalName == "price")
{
this.TextBox5.Text = item.InnerText;
}
}
#endregion
#region 方法二
TextBox1.Text = node.SelectSingleNode("author").InnerText;
TextBox2.Text = node.SelectSingleNode("publisher").InnerText;
TextBox3.Text = node.SelectSingleNode("date").InnerText;
TextBox4.Text = node.SelectSingleNode("isbn").InnerText;
TextBox5.Text = node.SelectSingleNode("price").InnerText;
#endregion
}