我想通过解析 dotnet c# 中的以下 xml 来知道 ItemGroup 的名称。我尝试了各种选择,但无法得到它。基本上我想知道有 ItemGroup ,它可以更多。无论如何我们可以加载这个 xml 并获取 ItemGroups 的列表及其名称。
在这里,我希望 ItemGroup 名称为“cssfile_individual”,cssfile_individual2
<Project xmlns="http://schemas.microsoft.com/developer/MsBuild/2003">
<UsingTask TaskName="CssCompressorTask" AssemblyFile="Yahoo.Yui.Compressor.Build.MsBuild.dll" />
<UsingTask TaskName="JavaScriptCompressorTask" AssemblyFile="Yahoo.Yui.Compressor.Build.MsBuild.dll" />
<PropertyGroup>
</PropertyGroup>
<Target Name="Minify">
<ItemGroup>
<cssfile_individual Include="test1.css"/>
<cssfile_individual Include="test2.css"/>
<cssfile_individual Include="test3.css"/>
<cssfile_individual Include="test3.css"/>
</ItemGroup>
<ItemGroup>
<cssfile_individual2 Include="test1.css"/>
<cssfile_individual2 Include="test2.css"/>
<cssfile_individual2 Include="test3.css"/>
<cssfile_individual2 Include="test3.css"/>
</ItemGroup>
</Target>
</Project>
我尝试如下
XmlDocument objXML = new XmlDocument();
objXML.Load(path);
然后开始生孩子。
示例 XML 如下所示
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/MsBuild/2003">
<UsingTask TaskName="CompressorTask"
AssemblyFile="D:\JsCssCompressor\JsCssCompressor\bin\Yahoo.Yui.Compressor.Build.MsBuild.dll" />
<Target Name="MyTaskTarget">
<ItemGroup>
<JavaScriptFiles Include="C:\Work\Purchase_Flow\eBizSol_App\Release\WebSites\Websites\McAfee.Consumer.Website\UIDesign\LegacySite\Scripts\FlexDashboard\AddDevice.js"/>
</ItemGroup>
<CompressorTask
JavaScriptCompressionType="YuiStockCompression"
JavaScriptFiles="@(JavaScriptFiles)"
ObfuscateJavaScript="True"
PreserveAllSemicolons="False"
DisableOptimizations="Nope"
EncodingType="Default"
DeleteJavaScriptFiles="false"
LineBreakPosition="-1"
JavaScriptOutputFile="C:\Work\Purchase_Flow\eBizSol_App\Release\WebSites\Websites\McAfee.Consumer.Website\UIDesign\LegacySite\Scripts\FlexDashboard\MAA2.0.js"
LoggingType="ALittleBit"
ThreadCulture="en-us"
IsEvalIgnored="false"
/>
</Target>
</Project>