2011-05-16 145 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