public static XmlDocument CreateXmlDocument(Stream input) { using (XmlReader reader = XmlReader.Create(input, new XmlReaderSettings() { IgnoreWhitespace = true })) return(SharedUtil.CreateXmlDocument(reader)); }
public static XmlNodeType GetFirstXmlNodeType(string xml) { using (XmlReader xmlReader = SharedUtil.CreateXmlReader(xml)) { while (xmlReader.Read()) { if (xmlReader.NodeType != XmlNodeType.Comment) { return(xmlReader.NodeType); } } } return(XmlNodeType.None); }
public static XmlDocument CreateXmlDocument(string xml, bool preserveWhiteSpace) { XmlDocument xmlDocument = SharedUtil.CreateXmlDocument(); if (string.IsNullOrEmpty(xml)) { return(xmlDocument); } XmlReaderSettings settings = new XmlReaderSettings(); settings.IgnoreWhitespace = !preserveWhiteSpace; xmlDocument.PreserveWhitespace = preserveWhiteSpace; using (StringReader stringReader = new StringReader(xml)) { using (XmlReader reader = XmlReader.Create((TextReader)stringReader, settings)) xmlDocument.Load(reader); } return(xmlDocument); }
public static XmlDocument CreateXmlDocument(string xml) { switch (xml) { case "": case null: return(new XmlDocument() { XmlResolver = (XmlResolver)null }); default: XmlReaderSettings settings = new XmlReaderSettings(); settings.IgnoreWhitespace = true; using (StringReader stringReader = new StringReader(xml)) { using (XmlReader reader = XmlReader.Create((TextReader)stringReader, settings)) return(SharedUtil.CreateXmlDocument(reader)); } } }
public static XmlReader CreateXmlReader(string xml) { return(SharedUtil.CreateXmlReader(xml, false)); }
public static T XmlFileToObject <T>(string fileName) { return(SharedUtil.XmlStringToObject <T>(SharedUtil.LoadXmlDocumentFromFile(fileName).OuterXml)); }
public static XmlDocument LoadXmlDocumentFromFile(string fileName) { using (FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read)) return(SharedUtil.CreateXmlDocument((Stream)fileStream)); }