Hey guys, I'm kinda late on a college project and being kinda noobish to C# doesn't help either... Anyway:

using (XmlReader reader = XmlReader.Create("myXml.xml", settings))
            {
                reader.MoveToContent();
                reader.ReadStartElement("users");

                while (reader.ReadStartElement("user"))
                {
                    string userID = reader.ReadElementContentAsString("userID", "");
                    string userName = reader.ReadElementContentAsString("name", "");
                    reader.ReadEndElement();
                    lstContent.Items.Add(userID + " : " + userName);
                }
            }

I get an error with the while loop: Cannot implicitly convert type 'void' to 'bool'...

I'm thinking I should create a BOOL, and let the WHILE run as long as it is TRUE, and if it 'detects' the end it should change the BOOL to FALSE... So either is there a better way to doing this or how can I check the 'end' of my XML ?

Here's my XML code

<?xml version="1.0" encoding="utf-8"?>
<users>
  <user>
    <userID>1</userID>
    <name>Bobby</name>
  </user>
  <user>
    <userID>2</userID>
    <name>Bob</name>
  </user>
</users>

Wooow! I've got this:

reader.MoveToContent();
                reader.ReadStartElement("users");

                while (reader.Read())
                {
                    if (reader.IsStartElement("userID"))
                    {
                        int userID = reader.ReadElementContentAsInt("userID", "");
                        string userName = reader.ReadElementContentAsString("name", "");
                        reader.ReadEndElement();
                        lstContent.Items.Add(userID + " : " + userName);
                    }
                    
                }
This article has been dead for over six months. Start a new discussion instead.