# C1.Win.C1Editor.C1TextRange.SetXmlElement

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_Win_C1Editor_C1TextRange_SetXmlElement_" data-uid="C1.Win.C1Editor.C1TextRange.SetXmlElement*">SetXmlElement Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_Win_C1Editor_C1TextRange_SetXmlElement_" data-uid="C1.Win.C1Editor.C1TextRange.SetXmlElement*"></a>
<h4 id="C1_Win_C1Editor_C1TextRange_SetXmlElement_System_Xml_XmlElement_" data-uid="C1.Win.C1Editor.C1TextRange.SetXmlElement(System.Xml.XmlElement)">SetXmlElement(XmlElement)</h4>
<div class="markdown level1 summary"><p>Replaces the text range content with the given <code class="paramref">element</code> of <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.xml.xmlelement">XmlElement</a> type.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void SetXmlElement(XmlElement element)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub SetXmlElement(element As XmlElement)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.xml.xmlelement">XmlElement</a></td>
      <td><span class="parametername">element</span></td>
      <td><p>An XmlElement to replace the range content.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Win_C1Editor_C1TextRange_SetXmlElement_System_Xml_XmlElement__examples">Examples</h5>
<p>The example replaces selected text with a div XmlElement.
<pre><code class="lang-csharp">private void button1_Click(object sender, EventArgs e)
{
XmlElement node = c1Editor1.Document.CreateElement(&quot;div&quot;);
node.InnerText = &quot;New Element&quot;;
c1Editor1.Selection.SetXmlElement(node);
}</code></pre>

</div>
