XElement.ReplaceAll Method (Object[])

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Replaces the child nodes and the attributes of this element with the specified content.

Namespace:   System.Xml.Linq
Assembly:  System.Xml.Linq (in System.Xml.Linq.dll)

member ReplaceAll : 
        [<ParamArrayAttribute>] content:Object[] -> unit

Parameters

content
Type: System.Object[]

A parameter list of content objects.

This method first removes existing content and attributes. It then adds the specified content.

This method uses snapshot semantics—that is, it creates a separate copy of the new content before replacing the contents of the current element with the new content. This means that you can query the contents of the current element and use the results of the query as the specified new content.

For details about the valid content that can be passed to this function, see Valid Content of XElement and XDocument Objects1.

This method will raise the Changed and the Changing events.

The following example passes the results of a LINQ query to this method, replacing the contents of an element with the query results.

No code example is currently available or this language may not be supported.

This example produces the following output:


                <Root>
  <Child3>3</Child3>
  <Child4>4</Child4>
  <Child5>5</Child5>
</Root>

Universal Windows Platform
Available since 8
.NET Framework
Available since 3.5
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show: