Use XDeclaration,XElement, XAttribute to create an XDocument : XDeclaration : XML LINQ C# Source Code


Custom Search

C# Source Code » XML LINQ » XDeclaration »

 

Use XDeclaration,XElement, XAttribute to create an XDocument








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

class Program {
    static void Main(string[] args) {
        XDocument xml = new XDocument(new XDeclaration("1.0", "UTF-8", "yes"),
                                        new XElement("people",
                                            new XElement("idperson",
                                            new XAttribute("id", 1),
                                            new XAttribute("year", 2004),
                                            new XAttribute("salary", "100"))));

        System.IO.StringWriter sw = new System.IO.StringWriter();
        xml.Save(sw);
        Console.WriteLine(sw);
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo XML LINQ
» XDeclaration