1
Reply

Why Reader.Value is Null?

pedram

pedram

Apr 9 2013 12:58 AM
1.1k
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)