Ejemplo n.º 1
0
 public static XmlDocument CreateXmlDocument(Stream input)
 {
     using (XmlReader reader = XmlReader.Create(input, new XmlReaderSettings()
     {
         IgnoreWhitespace = true
     }))
         return(SharedUtil.CreateXmlDocument(reader));
 }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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));
                }
            }
        }
Ejemplo n.º 5
0
 public static XmlReader CreateXmlReader(string xml)
 {
     return(SharedUtil.CreateXmlReader(xml, false));
 }
Ejemplo n.º 6
0
 public static T XmlFileToObject <T>(string fileName)
 {
     return(SharedUtil.XmlStringToObject <T>(SharedUtil.LoadXmlDocumentFromFile(fileName).OuterXml));
 }
Ejemplo n.º 7
0
 public static XmlDocument LoadXmlDocumentFromFile(string fileName)
 {
     using (FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
         return(SharedUtil.CreateXmlDocument((Stream)fileStream));
 }