Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Help me to create a C# XML file (a student list with first name, last name, stat

ID: 3868893 • Letter: H

Question

Help me to create a C# XML file (a student list with first name, last name, state, and favorite color) that your.ASPX page reads and displays. Could you walk me through the procedure for making the XML file and how to create the XML reader? The problem I am having is putting it all together I made the XML file after that I get lost. Can you help me write the html source code. Then do you put anything in the design view if so what would you put their and finaly how do you get to where you put the behind code and can you show If I put my code to read my XML file there . Can someone show me how to put everything together? This is my XML file and code to read my XML File:

<?xml version="1.0" encoding="utf-8"?>

<Students>

<Student>

<FirstName>Abhi</FirstName>

<LastName>Shek</LastName>

<State>Ontario</State>

<FavoriteColor>Red</FavoriteColor>

</Student>

<Student>

<FirstName>Anu</FirstName>

<LastName>Ram</LastName>

<State>Alberta</State>

<FavoriteColor>Brown</FavoriteColor>

</Student>

<Student>

<FirstName>Arun</FirstName>

<LastName>Raj</LastName>

<State>NewFoundland</State>

<FavoriteColor>Orange</FavoriteColor>

</Student>

</Students>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace XMLdemo2
{
class program
{
static void Main(string[] args)
{
// Start with XmlReader object
//here, we try to setup Stream between the XML file and xmlReader
using (XmlReader reader = XmlReader.Create(@"C:UsersDarrenDocumentsVisual Studio 2015WebSitesWebSite7myData"))
{
while (reader.Read())
{
if (reader.IsStartElement())
{
//return only when you have START tag

switch (reader.Name.ToString())
{
case "FirstName":
Console.WriteLine("First Name of the Element is : " + reader.ReadString());
break;

case "LastName":
Console.WriteLine("Last Name of the Element is : " + reader.ReadString());
break;
case "State":
Console.WriteLine("Your State is : " + reader.ReadString());
break;
case "FavoriteColor":
Console.WriteLine("Your Favorite color is : " + reader.ReadString());
break;
}
}
Console.WriteLine("");
}
}
Console.ReadKey();
}
}
}

Explanation / Answer

<?xml version="1.0" encoding="utf-8"?>

<Students>

<Student>

<FirstName>Abhi</FirstName>

<LastName>Shek</LastName>

<State>Ontario</State>

<FavoriteColor>Red</FavoriteColor>

</Student>

<Student>

<FirstName>Anu</FirstName>

<LastName>Ram</LastName>

<State>Alberta</State>

<FavoriteColor>Brown</FavoriteColor>

</Student>

<Student>

<FirstName>Arun</FirstName>

<LastName>Raj</LastName>

<State>NewFoundland</State>

<FavoriteColor>Orange</FavoriteColor>

</Student>

</Students>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace XMLdemo2
{
class program
{
static void Main(string[] args)
{
// Start with XmlReader object
//here, we try to setup Stream between the XML file and xmlReader
using (XmlReader reader = XmlReader.Create(@"C:UsersDarrenDocumentsVisual Studio 2015WebSitesWebSite7myData"))
{
while (reader.Read())
{
if (reader.IsStartElement())
{
//return only when you have START tag

switch (reader.Name.ToString())
{
case "FirstName":
Console.WriteLine("First Name of the Element is : " + reader.ReadString());
break;

case "LastName":
Console.WriteLine("Last Name of the Element is : " + reader.ReadString());
break;
case "State":
Console.WriteLine("Your State is : " + reader.ReadString());
break;
case "FavoriteColor":
Console.WriteLine("Your Favorite color is : " + reader.ReadString());
break;
}
}
Console.WriteLine("");
}
}
Console.ReadKey();
}
}
}