2011-07-25 9 views
3

私のページにxmlファイル(facebookから)を読み込もうとしています。 エラーが発生しています。それを理解できません。ASP.NETのxml facebookファイルを読む

An error occurred while parsing EntityName. Line 12, position 53. 

任意の考え:

Dim ds As New DataSet 
Dim myURL As String = "http://www.facebook.com/feeds/page.php?id=68310606562&format=rss20" 

ds.ReadXml(myURL) 

は、これは例外をスロー?ありがとう!

答えて

1

myURLの内容は、あなたのURLであり、XMLファイル名ではありません。

あなたが次のことを試すことができますWebクライアントのDownloadString()methodまたは類似の方法

var client = new WebClient(); 
client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)"); 

var xmlData = client.DownloadString(url); 
+0

私もそれを試しました、私はこれを返します: – kylemac

+0

HTMLバック。しかし、ブラウザのリンクに行き、ソースを見るとXMLが見えます。 – kylemac

+0

ユーザーエージェントヘッダーを追加します(編集を参照) – jglouie

0

を経由して、このXMLコンテンツを取得するための要求を作成する最初の試み:

XmlDocument doc = new XmlDocument();    
WebRequest req = WebRequest.Create("http://www.facebook.com/feeds/page.php?id=68310606562&format=rss20"); 
WebResponse resp = req.GetResponse(); 
StreamReader reader = new StreamReader(resp.GetResponseStream()); 
string xml = reader.ReadToEnd(); 
doc.Load(xml); 

次のことができるようにするには、ログインする必要がありますFacebookからXMLを取得します。