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.

XNode::ReplaceWith Method

 

Replaces this node with the specified content.

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

NameDescription
System_CAPS_pubmethodReplaceWith(Object^)

Replaces this node with the specified content.

System_CAPS_pubmethodReplaceWith(array<Object^>^)

Replaces this node with the specified content.

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

This method will raise the Changed and the Changing events.

The XContainer stores its child nodes as a singly-linked list of XNode objects. This means that the ReplaceWith method must traverse the list of direct child nodes under the parent container. Therefore, using this method might affect your performance.

The following example uses this method to replace the contents of a node with different content.

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

This example produces the following output:


                <Root>
  <Child1>child1 content</Child1>
  <Child2>child2 content</Child2>
  <NewChild>new content</NewChild>
  <Child4>child4 content</Child4>
  <Child5>child5 content</Child5>
</Root>
Return to top
Show:
© 2017 Microsoft