Skip to content

Instantly share code, notes, and snippets.

@chrisntr
Created Dec 16, 2010
Embed
What would you like to do?
var str = "en-US";
var str2 = "f7e4d2b5-c6ea-df11-9264-00237de2db9e";
WebClient client = new WebClient();
//client.Encoding = new UTF8Encoding(true);
Uri uri = new Uri("http://catalog.zune.net/v3.2/" + str + "/apps/" + str2 + "?version=latest&clientType=WinMobile%207.0&store=Zest");
client.DownloadStringCompleted += (object s,DownloadStringCompletedEventArgs e) =>
{
if(e.Error == null)
{
Console.WriteLine ("No error, parse results");
Console.WriteLine (e.Result);
var xmlResult = e.Result;
if (xmlResult.StartsWith(_byteOrderMarkUtf8))
{
Console.WriteLine ("Remove BOM" + _byteOrderMarkUtf8.Length);
xmlResult = xmlResult.Remove(0, _byteOrderMarkUtf8.Length);
}
if (xmlResult.StartsWith(_byteOrderMarkUtf8))
{
Console.WriteLine ("Remove BOM Again" + _byteOrderMarkUtf8);
xmlResult = xmlResult.Remove(0, _byteOrderMarkUtf8.Length);
}
if (xmlResult.StartsWith(_byteOrderMarkUtf8))
{
Console.WriteLine ("Remove BOM Again" + _byteOrderMarkUtf8);
xmlResult = xmlResult.Remove(0, _byteOrderMarkUtf8.Length);
}
try
{
XDocument document = XDocument.Parse(xmlResult);
Console.WriteLine ("Fail before here...");
}
catch (Exception error)
{
Console.WriteLine ("Oops - " + error.Message);
}
}
};
client.DownloadStringAsync(uri);
// Console
No error, parse results
???<?xml version="1.0" encoding="utf-8"?> THE XML </a:feed>
Remove BOM1
Remove BOM Again?
Remove BOM Again?
Oops - Text node cannot appear in this state. Line 1, position 1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment