2011-05-16 149 views
0

在這是XML文件我必須得到列表中的所有源DLL。 我正在嘗試以下查詢。 (新的System.Windows.Resources.StreamResourceInfo(e.Result,Nothing),新的Uri(「AppManifest.xaml」,UriKind.Relative))。 .Stream).ReadToEnd()需要LINQ查詢來讀取返回列表的XML文件

昏暗deploymentRoot作爲的XElement = XDocument.Parse(appManifest).Root **昏暗份作爲表(中的XElement)=(從assemblyParts在_ deploymentRoot.Elements()。元素()Select assemblyParts).ToList()**

但是patrs包含count.It不是一個列表。 我該怎麼做?

下面是XML文檔。

<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment" 
      RuntimeVersion="4.0.50826.0"> 
    <Deployment.OutOfBrowserSettings> 
     <OutOfBrowserSettings ShortName="WebPortalUI Application" 
           EnableGPUAcceleration="False" 
           ShowInstallMenuItem="True"> 
      <OutOfBrowserSettings.Blurb> 
       WebPortalUI Application on your desktop; 
       at home, at work or on the go. 
      </OutOfBrowserSettings.Blurb> 
      <OutOfBrowserSettings.WindowSettings> 
       <WindowSettings Title="WebPortalUI Application" 
           Height="400" Width="928" /> 
      </OutOfBrowserSettings.WindowSettings> 
      <OutOfBrowserSettings.Icons /> 
     </OutOfBrowserSettings> 
    </Deployment.OutOfBrowserSettings> 

    <Deployment.Parts> 
     <AssemblyPart x:Name="WebPortalUI" 
         Source="WebPortalUI.dll" /> 
     <AssemblyPart x:Name="System.ComponentModel.Composition" 
         Source="System.ComponentModel.Composition.dll" /> 
     <AssemblyPart x:Name="System.ComponentModel.Composition.Initialization" 
         Source="System.ComponentModel.Composition.Initialization.dll" /> 
     <AssemblyPart x:Name="System.ComponentModel.DataAnnotations" 
         Source="System.ComponentModel.DataAnnotations.dll" /> 
     <AssemblyPart x:Name="System.Windows.Controls.Data.Input" 
         Source="System.Windows.Controls.Data.Input.dll" /> 
     <AssemblyPart x:Name="System.Windows.Controls.Navigation" 
         Source="System.Windows.Controls.Navigation.dll" /> 
     <AssemblyPart x:Name="System.Xml.Linq" 
         Source="System.Xml.Linq.dll" /> 
     <AssemblyPart x:Name="System.Xml.Serialization" 
         Source="System.Xml.Serialization.dll" /> 
     <AssemblyPart x:Name="Telerik.Windows.Controls" 
         Source="Telerik.Windows.Controls.dll" /> 
     <AssemblyPart x:Name="Telerik.Windows.Controls.Docking" 
         Source="Telerik.Windows.Controls.Docking.dll" /> 
     <AssemblyPart x:Name="Telerik.Windows.Controls.GridView" 
         Source="Telerik.Windows.Controls.GridView.dll" /> 
     <AssemblyPart x:Name="Telerik.Windows.Controls.Input" 
         Source="Telerik.Windows.Controls.Input.dll" /> 
     <AssemblyPart x:Name="Telerik.Windows.Controls.Navigation" 
         Source="Telerik.Windows.Controls.Navigation.dll" /> 
     <AssemblyPart x:Name="Telerik.Windows.Data" 
         Source="Telerik.Windows.Data.dll" /> 
     <AssemblyPart x:Name="ViewModel" 
         Source="ViewModel.dll" /> 
     <AssemblyPart x:Name="System.Windows.Data" 
         Source="System.Windows.Data.dll" /> 
    </Deployment.Parts> 

</Deployment> 

回答

0

使用LINQ的回答是: http://forums.asp.net/t/1681678.aspx/1

從那裏複製:

Dim assemblySources = From aPart In XDocument.Load().Descendants("AssemblyPart") select a.Attribute("Source").Value 
For Each item As string In assemblySources 
    Console.WriteLine(item) 
Next 
+0

不錯,但在這裏寫一個關於此代碼摘要的簡短摘要。 – nalply 2012-10-11 18:19:01