XElement namespace

In this chapter you will learn:

  1. Create XElement with namespace

Create XElement with namespace

using System;//  j a  va 2 s .co  m
using System.Linq;
using System.Xml.Linq;
using System.Collections;
using System.Collections.Generic;


public class MainClass{
   public static void Main(){

        XNamespace aw = "http://www.domain.com";
        XElement root = new XElement(aw + "Root");
        Console.WriteLine(root);
   }
}

Next chapter...

What you will learn in the next chapter:

  1. Add an attribute to the root node
Home » C# Tutorial » XML Linq
XDocument
Create XDocument
Add to XDocument
Parse XML file with XDocument
Load XML string with XDocument
XDocument Root
Query XML document with Linq
Save XML document
XDocument Serialize
XElement namespace
Adding attribute
XElement's NextNode
XAttribute
XAttribute value
XAttribute Properties
XAttribute namespace
XComment
XDeclaration
XML declaration
XCData
XNamespace