XML Initialize Data from file path - CSharp System.Xml

CSharp examples for System.Xml:XML File

Description

XML Initialize Data from file path

Demo Code


using System.Xml.Linq;
using System;//from w w  w .ja  v  a2s  .  c  om

public class Main{
        public static string XMLInitializeData(string strXMLFile, string strNodeName)
        {
            string controllerXML = string.Empty;
            XElement ugat = XElement.Load(@"C:\Controllers\" + strXMLFile + ".xml");

            //controller = ugat.Elements("SearchSubmissionAPIControllerTest").Element("controller").Value;
            var elements = ugat.Elements(strNodeName);

            foreach (var item in elements)
            {
                controllerXML = item.Value;
            }

            return controllerXML;
        }
}

Related Tutorials