XElement.SetAttributeValue : XElement « System.Xml.Linq « C# / C Sharp by API






XElement.SetAttributeValue

   
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
using System.Xml.Linq;
public class MainClass {
    public static void Main() {
        XElement firstParticipant;
        XDocument xDocument = new XDocument(
          new XElement("Books", firstParticipant =
            new XElement("Book",
              new XAttribute("type", "Author"),
              new XAttribute("experience", "first-time"),
              new XElement("FirstName", "J"),
              new XElement("LastName", "R"))));

        Console.WriteLine(xDocument);
        firstParticipant.SetAttributeValue("type", "beginner");
        firstParticipant.SetAttributeValue("language", "English");
        firstParticipant.SetAttributeValue("experience", null);
        Console.WriteLine(xDocument);
    }
}

   
    
    
  








Related examples in the same category

1.new XElement
2.XElement.AddFirst
3.XElement.Ancestors()
4.XElement.AncestorsAndSelf()
5.XElement.AncestorsAndSelf(String tagName)
6.XElement.Attribute
7.XElement.Changed
8.XElement.Changing
9.XElement.Descendants
10.XElement.Descendants("firstname").First()
11.XElement.Elements
12.XElement.First
13.XElement.FirstAttribute
14.XElement.GetSchemaInfo()
15.XElement.HasAttributes
16.XElement.HasElements
17.XElement.Load(String fileName)
18.XElement.Nodes()
19.XElement.Parent
20.XElement.Parse(String xml value)
21.XElement.Remove
22.XElement.RemoveAll
23.XElement.Save(String fileName)
24.XElement.SetElementValue