[C#][Tips][File] XML:要素値リスト


public static void mRead_SelectNodes_InnerText()
{
    List<string> slValue = new List<string>(); 

    /* File */
    var xDoc = new System.Xml.XmlDocument();
    xDoc.Load(@"CustomersOrdwes.xml");

    /* Node(List) */
    string sXPath = @"/Root/Customers/Customer/CompanyName";
    System.Xml.XmlNodeList xNodeList = xDoc.SelectNodes(sXPath);

    /* Element */
    foreach (System.Xml.XmlNode item in xNodeList)
    {
        slValue.Add(item.InnerText);
    }

    /*  */
    slValue.ForEach(c => Console.WriteLine(c));
}