Get Config As Xml Document - CSharp System.Xml

CSharp examples for System.Xml:XML Document

Description

Get Config As Xml Document

Demo Code


using System.Xml.Linq;
using System.Linq;
using System.Reflection;
using System.Security.Permissions;
using System.IO;//from w w  w  .ja  v a 2s  . c  o m
using System.Collections;
using System.Xml;
using System.Text;
using System.Collections.Generic;
using System;

public class Main{
        public static XmlDocument GetConfigAsXmlDocument(Stream resourceStream)
        {
            XmlDocument document = new XmlDocument();
            XmlTextReader reader = null;
            try
            {
                reader = new XmlTextReader(resourceStream);
                document.Load(reader);
            }
            catch (Exception exception)
            {
                //
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
            return document;
        }
        public static XmlDocument GetConfigAsXmlDocument(string resourcePath)
        {
            XmlDocument document = new XmlDocument();
            XmlTextReader reader = null;
            try
            {
                reader = new XmlTextReader(resourcePath);
                document.Load(reader);
            }
            catch (Exception exception)
            {
                //
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
            return document;
        }
}

Related Tutorials