ASP.NET XmlDocument- Using GetElementsByTagName with index

XmlDocument- Using GetElementsByTagName with index in asp.net xml
GetElementsBytagNameIndex.aspx
<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Import Namespace="System.Xml" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    void Button1_Click(object sender, System.EventArgs e)
    {
        BulletedList1.Items.Clear();
        string xmlPath = Request.PhysicalApplicationPath + @"App_Data\ITBookList.xml";
        XmlDocument xmlDoc = new XmlDocument();
        xmlDoc.Load(xmlPath);
        XmlNode nameNode = xmlDoc.GetElementsByTagName(TextBox1.Text)[3];
        BulletedList1.Items.Add(nameNode.FirstChild.Value);
    }
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>XmlDocument- Using GetElementsByTagName with index in asp.net xml</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:DarkBlue; font-style:italic;">XmlDocument Example: GetElementsByTagName With Index</h2>
        <asp:Label 
            ID="Label1" 
            runat="server"
            Font-Bold="true"
            Text="Input Node Name"
            ForeColor="DeepPink"
            >
        </asp:Label>
        <asp:TextBox 
            ID="TextBox1"
            runat="server"
            Text="name"
            ForeColor="Snow"
            Width="250"
            BackColor="DeepPink"
            Height="35"
            Font-Bold="true"
            >
        </asp:TextBox>
        <br /><br />
        <asp:Button 
            ID="Button1"
            runat="server"
            OnClick="Button1_Click"
            Text="Find Nodes [GetElementsByTagName] With Index [3]"
            Height="42"
            Font-Bold="true"
            ForeColor="SaddleBrown"
            />
        <br /><br />  
        <asp:BulletedList 
            ID="BulletedList1"
            runat="server"
            ForeColor="HotPink"
            Font-Size="Large"
            BulletStyle="Square"
            Font-Names="Comic Sans MS"
            >
        </asp:BulletedList>
    </div>
    </form>
</body>
</html>
ITBookList.xml
ITBookList.xml source code here.

   






Related asp.net example