Adding attribute
In this chapter you will learn:
Add an attribute to the root node
using System;// j a va2s.c o m
using System.Data;
using System.Linq;
using System.Text;
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"));
// Add an attribute to the root node.
NewDoc.Element("Root").Add(new XAttribute("MyAttr", "Attribute Value"));
}
}
Next chapter...
What you will learn in the next chapter:
Home » C# Tutorial » XML Linq