XElement::ReplaceAll Method (Object^)
Replaces the child nodes and the attributes of this element with the specified content.
Assembly: System.Xml.Linq (in System.Xml.Linq.dll)
Parameters
- content
-
Type:
System::Object^
The content that will replace the child nodes and attributes of this element.
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.
The following example uses this method.
This example produces the following output:
<Root>
<NewChild>n</NewChild>
</Root>
<Root NewAttribute="n" />
<Root>Some text</Root>
<Root>12.345</Root>
<Root>2006-10-06T12:30:00</Root>
<Root>abcdefghi</Root>
<Root>
<NewChild1>1</NewChild1>
<NewChild2>2</NewChild2>
<NewChild3>3</NewChild3>
</Root>
<Root NewAtt1="1" NewAtt2="2" NewAtt3="3" />
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