Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Unlike <a href="http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.load.aspx"><code>XmlDocument.Load</code></a>, <a href="http://msdn.microsoft.com/en-us/library/system.xml.linq.xdocument.load.aspx"><code>XDocument.Load</code></a> is a static method <em>returning</em> a new <code>XDocument</code>:</p> <pre><code>XDocument doc = XDocument.Load(new StringReader(sr.ReadToEnd())); </code></pre> <p>It seems pretty pointless to read the stream to the end <em>then</em> create a <code>StringReader</code> though. It's also pointless creating the <code>StreamReader</code> in the first place - and if the XML document <em>isn't</em> in UTF-8, it could cause problems. Better:</p> <p>For .NET 4, where there's an <code>XDocument.Load(Stream)</code> overload:</p> <pre><code>using (var response = request.GetResponse()) { using (var stream = response.GetResponseStream()) { var doc = XDocument.Load(stream); } } </code></pre> <p>For .NET 3.5, where there isn't:</p> <pre><code>using (var response = request.GetResponse()) { using (var stream = response.GetResponseStream()) { var doc = XDocument.Load(XmlReader.Create(stream)); } } </code></pre> <p>Or alternatively, just let LINQ to XML do <em>all</em> the work:</p> <pre><code>XDocument doc = XDocument.Load(url); </code></pre> <p>EDIT: Note that the compiler error did give you enough information to get you going: it told you that you can't call <code>XDocument.Load</code> as <code>doc.Load</code>, and to give the type name instead. Your next step should have been to consult the documentation, which of course gives examples.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload