0% found this document useful (0 votes)
64 views

Practical 15 Dotnet 228336 PDF

The document contains code for an XML file defining TV channels and their attributes like name, language, and category. It also contains code for an ASP.NET page with dropdown lists to filter the channels by language and category. When the "Show" button is clicked, it loads the XML, filters the channels based on the dropdown selections, and displays the matching channel names on the page.

Uploaded by

Apexmens Mems
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views

Practical 15 Dotnet 228336 PDF

The document contains code for an XML file defining TV channels and their attributes like name, language, and category. It also contains code for an ASP.NET page with dropdown lists to filter the channels by language and category. When the "Show" button is clicked, it loads the XML, filters the channels based on the dropdown selections, and displays the matching channel names on the page.

Uploaded by

Apexmens Mems
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Practical no 15

Channel.xml
<?xml version="1.0" encoding="utf-8" ?>
<CableTV>
<Channel name="POGO">
<Language>Hindi</Language>
<Categary>Cartoon</Categary>
</Channel>

<Channel name="Disney">
<Language>English</Language>
<Categary>Cartoon</Categary>
</Channel>

<Channel name="AajTak">
<Language>Hindi</Language>
<Categary>News</Categary>
</Channel>

<Channel name="History">
<Language>English</Language>
<Categary>News</Categary>
</Channel>

</CableTV>

XmlTest.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="XmlTest.aspx.cs"
Inherits="practical_15.XmlTest" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<table class="auto-style1">
<tr>
<td>
<h2>Monkey.D.Luffy</h2>
</td>
<td>&nbsp;</td>
</tr><tr>
<td>&nbsp;</td>
<td>&nbsp;</td></tr>
</table>
<table class="auto-style1">
<tr><td>
<asp:DropDownList ID="ddlChannel" runat="server" AutoPostBack="True">
<asp:ListItem>Cartoon</asp:ListItem>
<asp:ListItem>News</asp:ListItem>
</asp:DropDownList>
</td><td>
<asp:DropDownList ID="ddlLanguage" runat="server" AutoPostBack="True">
<asp:ListItem>English</asp:ListItem>
<asp:ListItem>Hindi</asp:ListItem>
</asp:DropDownList>
</td></tr><tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr><tr><td>
<asp:Button ID="btnShow" runat="server" OnClick="btnShow_Click"
Text="Show" />
</td><td>&nbsp;</td>
</tr><tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr><tr><td>
<asp:Label ID="lblResult" runat="server" Text="ore datte kaizoku ni naritain da
yo"></asp:Label>
</td>
<td>&nbsp;</td>
</tr>
</table>
</div>
</form>
</body>
</html>
XmlTest.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
namespace practical_15
{
public partial class XmlTest : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

protected void btnShow_Click(object sender, EventArgs e)


{
XmlDocument doc = new XmlDocument();
doc.Load("C:\\Users\\prath\\source\\repos\\practical 15\\practical 15\\Channels.xml");
lblResult.Text = "ore datte kaizoku ni naritain da yo";
foreach (XmlElement element in doc.DocumentElement.ChildNodes) {
String ch = element.GetAttribute("name");
if ((element.ChildNodes[1].InnerText == ddlChannel.Text) &&
(element.ChildNodes[0].InnerText == ddlLanguage.Text))
{
lblResult.Text = ch + "<br>";
}
}
}
}
}
Output:

You might also like