馬庫斯在這裏。我遇到了一個難以解決的問題。顯然,我有一個連接到dotnetzonereader的Windows 7手機編碼的例子。那麼我試圖改變網址到www.google.com,但它無法這樣做。在這裏,我不是指訪問www.google.com的Windows 7模擬器中的Internet Explorer,但是我正在討論訪問Internet的應用程序。這是我從網上獲得的代碼的一個例子。我試過改變這個部分> dzoneRss.DownloadStringAsync(new Uri(「http://feeds.dzone.com/zones/dotnet」)); to dzoneRss.DownloadStringAsync(new Uri(「http://google.com」)); 但仍有錯誤。任何一種靈魂都會在這裏幫助我完成這個T_T。感謝人們。真的三江源將Windows 7手機模擬器連接到自己的網站?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
namespace DotNetZoneReader
{
public partial class MainPage : PhoneApplicationPage
{
public MainPage()
{
InitializeComponent();
SupportedOrientations = SupportedPageOrientation.Portrait | SupportedPageOrientation.Landscape;
}
private void listBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
}
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
}
private void storyList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
}
private void button1_Click(object sender, RoutedEventArgs e)
{
var dzoneRss = new WebClient();
dzoneRss.DownloadStringCompleted += dzoneRss_DownloadStringCompleted;
dzoneRss.DownloadStringAsync(new Uri("http://feeds.dzone.com/zones/dotnet"));
}
private void dzoneRss_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error != null) return;
XElement xmlStories = XElement.Parse(e.Result);
XNamespace dz = "http://www.developerzone.com/modules/dz/1.0";
storyList.ItemsSource = from story in xmlStories.Descendants("item")
select new FeedItem
{
Title = story.Element("title").Value,
Description = story.Element("description").Value,
Link = story.Element("link").Value,
PublishDate = Convert.ToDateTime(story.Element(dz + "submitDate").Value).ToString("dd-MMM"),
Author = story.Element(dz + "submitter").Element(dz + "username").Value,
AuthorImageUrl = story.Element(dz + "submitter").Element(dz + "userimage").Value
};
}
public class FeedItem
{
public string Title { get; set; }
public string Description { get; set; }
public string Link { get; set; }
public string PublishDate { get; set; }
public string Author { get; set; }
public string AuthorImageUrl { get; set; }
}
}
}
你遇到了什麼確切的錯誤?你想做什麼?如果您正在加載的頁面沒有定義XML名稱空間(並且不是XML格式),那麼您肯定會得到一個錯誤。 – 2010-11-02 04:21:26
嗨馬庫斯,你的代碼爲你工作之前,你改變的網址?你從哪一行得到的錯誤是什麼? – 2010-11-02 04:22:57
感謝Dennis和Mick的回答。正如我所提到的,這是我從網上檢索到的dotnetzonereader的示例。如果你們可以將我上面提到的代碼複製到Microsoft Visual Studio 2010 Express For Windows Phone中,那將會很棒。一旦我按下刷新按鈕,它使我能夠看到網頁http://feeds.dzone.com/zones/dotnet。不過,我試圖改變它,讓我訪問谷歌。我的問題是我必須改變哪部分代碼,然後我才能訪問谷歌?謝謝@米克@丹尼爾 – marcus 2010-11-02 07:42:39