Skip to content
This repository was archived by the owner on Apr 11, 2021. It is now read-only.

Commit 3e377b1

Browse files
Update BookUpdates
chapter 27, XDocument.Load uses a stream instead of an HTTP URL.
1 parent 272298c commit 3e377b1

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

BookUpdates.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,24 @@ public static MySafe InitProtection()
188188
}
189189
```
190190

191+
## Chapter 27 - XML and JSON
192+
193+
Page 812, the Load method of the XDocument class supports only loading of local files (the .NET Framework version of this method supports loading files from HTTP servers as well). The sample code for the `QueryFeed` method needs to be changed. The HttpClient class is used to make a HTTP GET requests to return a stream. The stream is passed to the XDocument.Load method:
194+
195+
```csharp
196+
public static async void QueryFeed()
197+
{
198+
try
199+
{
200+
var httpClient = new HttpClient();
201+
using (Stream stream = await httpClient.GetStreamAsync("http://csharp.christiannagel.com/feed/atom/"))
202+
{
203+
XNamespace ns = "http://www.w3.org/2005/Atom";
204+
XDocument doc = XDocument.Load(stream);
205+
206+
WriteLine($"Title: {doc.Root.Element(ns + "title").Value}");
207+
```
208+
191209
## Chapter 29 - Core XAML
192210

193211
Page 852, the minimum UWP application needs a change to use a custom class derived from the *Application* class. The *Main* method is now changed to this:

0 commit comments

Comments
 (0)