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; }