XElement.ReplaceAttributes 메서드

정의

이 요소의 특성을 지정된 콘텐츠로 바꿉니다.

오버로드

ReplaceAttributes(Object[])

이 요소의 특성을 지정된 콘텐츠로 바꿉니다.

ReplaceAttributes(Object)

이 요소의 특성을 지정된 콘텐츠로 바꿉니다.

예제

다음 예제에서는 세 가지 특성이 있는 요소를 만듭니다. 그런 다음 이 메서드를 사용하여 요소의 모든 특성을 단일 특성으로 대체합니다.

XElement root = new XElement("Root",
    new XAttribute("Att1", 1),
    new XAttribute("Att2", 2),
    new XAttribute("Att3", 3)
);
root.ReplaceAttributes(
    new XAttribute("NewAtt1", 101)
);
Console.WriteLine(root);
Dim root As XElement = <Root Att1="1" Att2="2" Att3="3"/>
root.ReplaceAttributes(New XAttribute("NewAtt1", 101))
Console.WriteLine(root)

이 예제는 다음과 같은 출력을 생성합니다.

<Root NewAtt1="101" />

설명

이 메서드는 및 이벤트를 발생 Changed 합니다 Changing .

이 함수에 전달할 수 있는 유효한 콘텐츠에 대한 자세한 내용은 XElement 및 XDocument 개체의 유효한 콘텐츠를 참조하세요.

ReplaceAttributes(Object[])

Source:
XElement.cs
Source:
XElement.cs
Source:
XElement.cs

이 요소의 특성을 지정된 콘텐츠로 바꿉니다.

public:
 void ReplaceAttributes(... cli::array <System::Object ^> ^ content);
public void ReplaceAttributes (params object[] content);
public void ReplaceAttributes (params object?[] content);
member this.ReplaceAttributes : obj[] -> unit
Public Sub ReplaceAttributes (ParamArray content As Object())

매개 변수

content
Object[]

콘텐츠 개체의 매개 변수 목록입니다.

예제

다음 예제에서는 세 가지 특성이 있는 요소를 만듭니다. 그런 다음 특성을 다른 특성으로 바꿉니다.

XElement root = new XElement("Root",
    new XAttribute("Att1", 1),
    new XAttribute("Att2", 2),
    new XAttribute("Att3", 3)
);
root.ReplaceAttributes(
    new XAttribute("NewAtt1", 101),
    new XAttribute("NewAtt2", 102),
    new XAttribute("NewAtt3", 103)
);
Console.WriteLine(root);
Dim root As XElement = <Root Att1="1" Att2="2" Att3="3"/>
root.ReplaceAttributes( _
New XAttribute("NewAtt1", 101), _
New XAttribute("NewAtt2", 102), _
New XAttribute("NewAtt3", 103))
Console.WriteLine(root)

이 예제는 다음과 같은 출력을 생성합니다.

<Root NewAtt1="101" NewAtt2="102" NewAtt3="103" />

설명

이 메서드는 먼저 기존 특성을 제거합니다. 그런 다음 지정된 content를 추가합니다.

이 함수에 전달할 수 있는 유효한 콘텐츠에 대한 자세한 내용은 XElement 및 XDocument 개체의 유효한 콘텐츠를 참조하세요.

이 메서드는 및 이벤트를 발생 Changed 합니다 Changing .

추가 정보

적용 대상

ReplaceAttributes(Object)

Source:
XElement.cs
Source:
XElement.cs
Source:
XElement.cs

이 요소의 특성을 지정된 콘텐츠로 바꿉니다.

public:
 void ReplaceAttributes(System::Object ^ content);
public void ReplaceAttributes (object content);
public void ReplaceAttributes (object? content);
member this.ReplaceAttributes : obj -> unit
Public Sub ReplaceAttributes (content As Object)

매개 변수

content
Object

이 요소의 특성을 대체할 콘텐츠입니다.

예제

다음 예제에서는 세 가지 특성이 있는 요소를 만듭니다. 그런 다음 이 메서드를 사용하여 요소의 모든 특성을 단일 특성으로 대체합니다.

XElement root = new XElement("Root",
    new XAttribute("Att1", 1),
    new XAttribute("Att2", 2),
    new XAttribute("Att3", 3)
);
root.ReplaceAttributes(
    new XAttribute("NewAtt1", 101)
);
Console.WriteLine(root);
Dim root As XElement = <Root Att1="1" Att2="2" Att3="3"/>
root.ReplaceAttributes(New XAttribute("NewAtt1", 101))
Console.WriteLine(root)

이 예제는 다음과 같은 출력을 생성합니다.

<Root NewAtt1="101" />

설명

이 메서드는 먼저 기존 특성을 제거합니다. 그런 다음 지정된 content를 추가합니다.

이 함수에 전달할 수 있는 유효한 콘텐츠에 대한 자세한 내용은 XElement 및 XDocument 개체의 유효한 콘텐츠를 참조하세요.

이 메서드는 및 이벤트를 발생 Changed 합니다 Changing .

추가 정보

적용 대상