string xml = "true "; using (XmlReader reader = XmlReader.Create(new StringReader(xml))) { reader.ReadToFollowing("myBoolean"); bool value = reader.ReadContentAsBoolean(); Console.WriteLine(value); // outputs: True }
using (XmlReader reader = XmlReader.Create("myFile.xml")) { reader.ReadToFollowing("myBoolean1"); bool value1 = reader.ReadContentAsBoolean(); reader.ReadToFollowing("myBoolean2"); bool value2 = reader.ReadContentAsBoolean(); Console.WriteLine(value1); // outputs the value of myBoolean1 Console.WriteLine(value2); // outputs the value of myBoolean2 }The System.Xml.XmlReader class is part of the .NET Framework, which is included with Microsoft Visual Studio. It can be found in the System.Xml.dll library.