Get the document part of a XDocument in CSharp

Description

The following code shows how to get the document part of a XDocument.

Example


//from   w  w  w  .ja va 2  s. c  o  m
using System;
using System.Linq;
using System.Xml;
using System.Xml.Linq;
using System.IO;


public class MainClass{

   public static void Main(string[] args){   
      XDocument NewDoc = new XDocument(
            new XDeclaration("1.0", "utf-8", "yes"),
            new XElement("Root", "MyDoc"));

     // Display it on screen.
      Console.WriteLine(NewDoc.Declaration.ToString() +
            "\r\n" + NewDoc.Document.ToString());


   }
}




















Home »
  C# Tutorial »
    XML »




Load Parse
Document
Element
Attribute
Namespace
Query
Save
Schema
Style