在这是XML文件中,我必须在列表中获取所有Source dll。 我正在尝试以下查询。
Dim appManifest As String = New System.IO.StreamReader(Application.GetResourceStream(New System.Windows.Resources.StreamResourceInfo(e.Result,Nothing),New Uri(“AppManifest.xaml”,UriKind.Relative))。流).ReadToEnd()
Dim deploymentRoot As XElement = XDocument.Parse(appManifest).Root ** Dim parts作为List(Of XElement)=(来自assemblyParts In _ deploymentRoot.Elements()。Elements()选择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 :(得分:0)
您是否尝试过使用xpath? 查询将类似于// AssemblyPart / [Source]
XPath general:http://www.w3schools.com/xpath/default.asp
XPath&amp; .Net:http://www.developer.com/net/net/article.php/3383961/NET-and-XML-XPath-Queries.htm
欢呼声
答案 1 :(得分: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