I am a beginner programmer starting off with C#, and web services.
In the Service.cs file of my web service, I create a ReadXMLFile() meth
The reason its not working because, example: when reader.Name == "firstname" is true but its not true with its elements value. What it exactly means is reader object reads next Nodetype, which is XmlNodeType.Element. So in this case looking at your XML file, using reader.Read(); function again reads next node, which is XmlNodeType.Text, and its value is then Joe. Im givin you example of working version.
void ReadXMLFile()
{
XmlTextReader reader = new XmlTextReader("ClassRoll.xml");
reader.Read();
while (reader.Read())
{
if (reader.Name == "id")
{
reader.Read();
if(reader.NodeType == XmlNodeType.Text)
{
id = reader.Value;
reader.Read();
}
}
}
}