title: c# XDocument : Check if particular node name exists , if not add
body: <p>I have below node which needs to be added in xslt if not exists :-</p>
  
  <pre><code>&lt;xsl:template name="URLSpliter"&gt;
      &lt;xsl:param name="url" /&gt;
      &lt;xsl:variable name="splitURL" select="substring-after($url, '/')" /&gt;
      &lt;xsl:if test="contains($splitURL, '/')"&gt;
        &lt;!--To call the template recursively--&gt;
        &lt;xsl:call-template name="URLSpliter"&gt;
          &lt;xsl:with-param name="url" select="$splitURL" /&gt;
        &lt;/xsl:call-template&gt;
      &lt;/xsl:if&gt;
      &lt;xsl:if test="not(contains($splitURL, '/'))"&gt;
        &lt;xsl:value-of select="$splitURL" /&gt;
      &lt;/xsl:if&gt;
    &lt;/xsl:template&gt;
  </code></pre>
  
  <p>For this, first I need to check if it exists or not ?-</p>
  
  <p>I have checked it through -</p>
  
  <pre><code>IEnumerable&lt;XElement&gt; xElements = from xmlAuthor in doc.Descendants()
                                                        let xElement = xmlAuthor.Element("URLSpliter")
                                                        where xElement != null 
                                                        select xmlAuthor;
  
                      var IsUrlSplitterExists= xElements.Any();
  
                      if(IsUrlSplitterExists)
                      {
  
                      }
  </code></pre>
  
  <p>1.I want to know if its correct way or not?</p>
  
  <ol start="2">
  <li>If not exists (element [name="URLSpliter"]) then needs to add.</li>
  </ol>
  
  <p>How can I add it as a first node of xslt?</p>