Use Two different namespaces in CSharp

Description

The following code shows how to use Two different namespaces.

Example


using System;/*from  w  w w .j a va2s.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";
        XNamespace fc = "www.anotherDomain.com";
        XElement root = new XElement(aw + "Root",
            new XAttribute("xmlns", "http://www.domain.com"),
            new XAttribute(XNamespace.Xmlns + "fc", "www.anotherDomain.com"),
            new XElement(fc + "Child",
                new XElement(aw + "DifferentChild", "other content")
            ),
            new XElement(aw + "Child2", "c2 content"),
            new XElement(fc + "Child3", "c3 content")
        );
        Console.WriteLine(root);
    }
}




















Home »
  C# Tutorial »
    XML »




Load Parse
Document
Element
Attribute
Namespace
Query
Save
Schema
Style