XDocument doc = new XDocument(新しいXDeclaration( "1.0"、 "utf-8"、 "true")、新しいXComment( "コメント")、新しいXElement( "従業員"、新しいXElement( "RootElement"、新しいXElement( " "Employee"、新しいXAttribute( "id"、 "123")、新しいXElement( "name"、 "John")、新しいXCData( "CData")))))。 // Selection multiple nodes var allEmployees = xdoc.Root.Elements( "Employees"); // Select single node var employeeJohn = xdoc.Root.Descendants()内のノード要素( "Employees")。要素( "Employee")ここで、node.Attribute( "id")値== "123"ノードを選択します。 // Insert node XElement newNode = new XElement( "NewNode"、 "Node content"); allEmployees.Add(newNode); // Delete node employeeJohn.Remove();