【发布时间】:2016-05-27 18:12:51
【问题描述】:
我正在解析 xml 文件,特别是节点,我必须先对其进行拆分,然后在其中执行添加操作,然后在其上方插入新节点。
我的 XML 文件:
<Project Default="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="1.0">
<Items>
<Resource Include="File\Scripts\Main.xml" />
<Resource Include="File\Scripts\File101_102.xml" />
</Items>
</project>
Powershell:
[xml]$xdoc = Get-Content $path
$NodeInsertAfter=$xdoc.project.Items.Resource[0]
$StringtoSplit=$xdoc.project.Items.Resource[1]
$a=$StringtoSplit.Include.ToString().split('\')
$a=$StringtoSplit.Include.ToString().split('\')
$a
我已经到达读取节点但是我将如何使用 split 函数来增加文件编号,即 File102_103.xml
我的输出必须是:
<Project Default="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="1.0">
<Items>
<Resource Include="File\Scripts\Main.xml" />
<Resource Include="File\Scripts\File102_103.xml" />
<Resource Include="File\Scripts\File101_102.xml" />
</Items>
【问题讨论】:
标签: xml powershell