LINQ To XML Element Text : XDocument « XML LINQ « C# / CSharp Tutorial






using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using System.Text;

    class Program{
        static void Main(string[] args){
            XDocument xdoc = new XDocument(
                new XElement("customers",
                    new XElement("customer",
                        "AAAAAA",
                        new XAttribute("City", "New York"),
                        new XAttribute("Region", "North America")
                        ),
                    new XElement("customer",
                        "BBBBBB",
                        new XAttribute("City", "Mumbai"),
                        new XAttribute("Region", "Asia")
                    )
                )
            );
            Console.WriteLine(xdoc);
        }
    }








31.1.XDocument
31.1.1.Save and Load XML
31.1.2.LINQ To XML Element Text
31.1.3.Use Tree to display xml document
31.1.4.Binding xml to DataGridView
31.1.5.Validate Schema for XDocument