Get the next attribute of the parent element in CSharp

Description

The following code shows how to get the next attribute of the parent element.

Example


   /*from  w w  w .j  ava  2 s. c o m*/
using System;
using System.Linq;
using System.Xml;
using System.Xml.Linq;
using System.Collections;
using System.Collections.Generic;

public class MainClass{
   public static void Main(){
        XElement root = new XElement("Root",
            new XAttribute("Att1", 1),
            new XAttribute("Att2", 2),
            new XAttribute("Att3", 3),
            new XAttribute("Att4", 4)
        );
        
        XAttribute att = root.FirstAttribute;
        do {
            Console.WriteLine(att);
        }
        while((att = att.NextAttribute) != null);
   }
}




















Home »
  C# Tutorial »
    XML »




Load Parse
Document
Element
Attribute
Namespace
Query
Save
Schema
Style