2012-04-13 9 views
0

私は自分のXMLを検索すると、それからアイテムを得ることができないのだろうと思っています。Retrieve XML WP7

私は基本的に私のWebサービスに接続するために電話を使用します。

XMLは、ディレクトリ情報とファイル情報のTUPLEを返します。私は右のURLからXMLをダウンロードした後、私は、コードのこの部分を使用しています

のWindows Phone 7アプリケーションに私のコードで
<TupleOfArrayOfDirectoryInfoArrayOfFileInfoe_PmhuPqo xmlns="http://schemas.datacontract.org/2004/07/System"  xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> 
<m_Item1 xmlns:a="http://schemas.datacontract.org/2004/07/System.IO"> 
<a:DirectoryInfo> 
<OriginalPath xmlns="" xmlns:b="http://www.w3.org/2001/XMLSchema" i:type="b:string">AETN</OriginalPath> 
<FullPath xmlns="" xmlns:b="http://www.w3.org/2001/XMLSchema"    i:type="b:string">C:\inetpub\wwwroot\Files\TEST1</FullPath> 
</a:DirectoryInfo> 
<a:DirectoryInfo> 
<OriginalPath xmlns="" xmlns:b="http://www.w3.org/2001/XMLSchema" i:type="b:string">BT</OriginalPath> 
<FullPath xmlns="" xmlns:b="http://www.w3.org/2001/XMLSchema"  i:type="b:string">C:\inetpub\wwwroot\Files\TEST2</FullPath> 
</a:DirectoryInfo> 
    <a:DirectoryInfo> 
<OriginalPath xmlns="" xmlns:b="http://www.w3.org/2001/XMLSchema" i:type="b:string">Comixology</OriginalPath> 
<FullPath xmlns="" xmlns:b="http://www.w3.org/2001/XMLSchema" i:type="b:string">C:\inetpub\wwwroot\Files\TEST3</FullPath> 
</a:DirectoryInfo> 

、:

void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) 
    { 
     if (e.Error == null) 
     { 
      XDocument xdoc = XDocument.Parse(e.Result, LoadOptions.None); 
      var folders = from query in xdoc.Descendants("DirectoryInfo") 
          select new Folder 
          { 
           Name = (string)query.Element("OriginalPath"), 
          }; 
      listBox2.ItemsSource = folders; 
     } 
    }  

私はこのエラーを取得する:

'System.Collections.IEnumerable' does not contain a definition for 'System' and no extension method 'System' accepting a first argument of type 'System.Collections.IEnumerable' could be found (are you missing a using directive or an assembly reference?) 
+0

あなたのソリューションを既にクリーニングして再構築しましたか?参照に問題があるようです。また、どのラインでエラーがスローされますか? –

+0

エラーはスローされません。空文字列のNAMEだけです。 – Kiwimoisi

+1

わかりません。あなたの質問では、あなたは参照についてのエラーを取得すると述べていますか? –

答えて

2

エラーについてはわかりませんが、要素が返されないという問題は、DirectoryInfo要素に名前空間が適用されているため、それを使用して検索する必要があります。

void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) 
{ 
    if (e.Error == null) 
    { 
     XDocument xdoc = XDocument.Parse(e.Result, LoadOptions.None); 

     XNamespace aNamespace = XNamespace.Get("http://schemas.datacontract.org/2004/07/System.IO"); 

     var folders = from query in xdoc.Descendants(aNamespace.GetName("DirectoryInfo")) 
         select new Folder 
         { 
          Name = (string)query.Element("OriginalPath"), 
         }; 
     listBox2.ItemsSource = folders; 
    } 
} 
関連する問題