Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

XElement::ReplaceAll Method

 

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)

NameDescription
System_CAPS_pubmethodReplaceAll(Object^)

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

System_CAPS_pubmethodReplaceAll(array<Object^>^)

Replaces the child nodes and the attributes of this element with 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. It queries the element that is having its contents replaced.

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

This example produces the following output:


                <Root>
  <Data>1</Data>
  <Data>2</Data>
  <Data>3</Data>
  <Data>4</Data>
  <Data>5</Data>
</Root>
-----
<Root>
  <NewData>3</NewData>
  <NewData>4</NewData>
  <NewData>5</NewData>
</Root>
Return to top
Show:
© 2017 Microsoft