Forum Replies Created
July 2, 2017 at 6:43 pm in reply to: What is the Difference Between IEnumerable and IQueryable in C# #1075RajeevKeymaster
The main difference between IEnumerable and IQueryable in C# is,
IEnumerable is suitable for querying data from in-memory collections such as Array and List.IEnumerable is beneficial for LINQ to XML and LINQ to Object queries.
IQueryable is suitable for querying data from out-of-memory collections such as databases.IQueryable is beneficial for Linq to SQL queries.RajeevKeymaster
There are various ways we can remove the version information of the xml file from C#.
XmlDocument xmlDoc = new XmlDocument();
foreach (XmlNode n in xmlDoc)
if (n.NodeType == XmlNodeType.XmlDeclaration)
Above if condition can be changed as below to remove the xml header information from an xml file.
if we blindly remove the first child from xml without an if check , it may remove xml root itself if xml version information not present in the xml.
if (xmlDoc.FirstChild.NodeType == XmlNodeType.XmlDeclaration)
//Remove the xml version,if it is the first child of the doc.
If xmldoc is made in string format,we can simply remove the xml version info from the xml file using the string.Replace statement.
string xmlDoc = stringXmlDoc.Replace(““, “”);
If we are writing an xml document and don’t want to write xml declaration in the xml doc then use the ConformanceLevel and OmitXmlDeclaration properties.
writer.Settings = new XmlWriterSettings();
writer.Settings.ConformanceLevel = ConformanceLevel.Fragment;
writer.Settings.OmitXmlDeclaration = true;