public string Read(string filePath) { string result = string.Empty; // Check correct path if (File.Exists(filePath) && (filePath.EndsWith(".xml"))) { // Role base security for the XML reading logic if (_roleProvider.CanReadXMLFile(filePath)) { using (XmlTextReader reader = new XmlTextReader(filePath)) { while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: // The node is an element. result += ("<" + reader.Name); result += (">"); break; case XmlNodeType.Text: //Display the text in each element. result += (reader.Value); break; case XmlNodeType.EndElement: //Display the end of the element. result += ("</" + reader.Name); result += (">"); break; } } } } } return(result); }