# C1.LiveLinq.LiveViews.Xml.XmlExtensions.AsLive

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_LiveLinq_LiveViews_Xml_XmlExtensions_AsLive_" data-uid="C1.LiveLinq.LiveViews.Xml.XmlExtensions.AsLive*">AsLive Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_LiveLinq_LiveViews_Xml_XmlExtensions_AsLive_" data-uid="C1.LiveLinq.LiveViews.Xml.XmlExtensions.AsLive*"></a>
<h4 id="C1_LiveLinq_LiveViews_Xml_XmlExtensions_AsLive_System_Xml_Linq_XDocument_" data-uid="C1.LiveLinq.LiveViews.Xml.XmlExtensions.AsLive(System.Xml.Linq.XDocument)">AsLive(XDocument)</h4>
<div class="markdown level1 summary"><p>Creates a view based on the specified XML document.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public static View&lt;XDocument&gt; AsLive(this XDocument document)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Shared Function AsLive(document As XDocument) As View(Of XDocument)</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.linq.xdocument">XDocument</a></td>
      <td><span class="parametername">document</span></td>
      <td><p>The XML document to expose as a view.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="C1.LiveLinq.LiveViews.View-1.html">View</a>&lt;<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.xml.linq.xdocument">XDocument</a>&gt;</td>
      <td><p>A view representing the specified XML document.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_LiveLinq_LiveViews_Xml_XmlExtensions_AsLive_System_Xml_Linq_XDocument__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>Since there can be only one root element in a document, the view based on a document (<code>document.AsLive()</code>) is 
similar to the view based on its root element (<code>document.Root.AsLive()</code>).
The difference is that the document view contains the document as its only item,
and the root view contains the root as its only item. This difference is essential only when
the root of the document is replaced with a different element (and so the whole XML tree changes), then
the document view remains valid and shows the changed document contents, whereas the root view becomes
disconnected from the document.</p>
<p><b>Note:</b> This view is owned by the <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.xml.linq.xdocument">XDocument</a> object (it is stored as one of its annotations),
so, if you create a view for the same document several times, it will be the same object.</p>
</div>


<a id="C1_LiveLinq_LiveViews_Xml_XmlExtensions_AsLive_" data-uid="C1.LiveLinq.LiveViews.Xml.XmlExtensions.AsLive*"></a>
<h4 id="C1_LiveLinq_LiveViews_Xml_XmlExtensions_AsLive_System_Xml_Linq_XElement_" data-uid="C1.LiveLinq.LiveViews.Xml.XmlExtensions.AsLive(System.Xml.Linq.XElement)">AsLive(XElement)</h4>
<div class="markdown level1 summary"><p>Creates a view based on the specified XML element.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public static View&lt;XElement&gt; AsLive(this XElement element)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Shared Function AsLive(element As XElement) As View(Of XElement)</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.linq.xelement">XElement</a></td>
      <td><span class="parametername">element</span></td>
      <td><p>The XML element to expose as a view.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="C1.LiveLinq.LiveViews.View-1.html">View</a>&lt;<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.xml.linq.xelement">XElement</a>&gt;</td>
      <td><p>A view representing the specified XML element.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_LiveLinq_LiveViews_Xml_XmlExtensions_AsLive_System_Xml_Linq_XElement__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>This view represents a single XML node. Therefore, as a collection of items, this view's <b>Count</b> is always 1.
This view is usually used as a starting point to construct a view containing elements or attributes 
from this node's descendants by using a query with operators from <a class="xref" href="C1.LiveLinq.LiveViews.Xml.XmlExtensions.html">XmlExtensions</a> such as <b>Elements</b>,
<b>Descendants</b> and others, in combination with standard LINQ query operators <b>where</b>, <b>join</b> and others.</p>
<p><b>Note:</b> This view is owned by the <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.xml.linq.xelement">XElement</a> object (it is stored as one of its annotations),
so, if you create a view for the same element several times, it will be the same object.</p>
</div>
</div>
