pedram

pedram

  • NA
  • 13
  • 12.5k

Why Reader.Value is Null?

Apr 9 2013 12:58 AM
When I run this block of code with if clause(if (reader.Name == ControlID)),Reader.Value returns null,but when I omit the if clause it returns the right Value.
Have you got any idea why this happens?
            XmlTextReader reader = new System.Xml.XmlTextReader("D:\\k.xml");             string contents = "";                           while (reader.Read())             {                 reader.MoveToContent();                 if (reader.Name == ControlID)                                    contents = reader.Value;             }

Answers (1)