내 powershell 코드는 실제로 XML에서 데이터를 읽고 특정 데이터를 csv 파일에 저장합니다. 내가 추출물 단지 "testing.dll"위의 XML 코드에서 필요Powershell 스크립트를 사용하여 주 문자열에서 부분 문자열을 제거하려면 어떻게해야합니까?
<?xml version="1.0" encoding="utf-8"?>
<Report Version="10.0">
<Targets>
<Target Name="\\bin\testBusiness.dll">
<Modules>
<Module Name="testing.dll" AssemblyVersion="1.0.1003.312" FileVersion="1.0.0.0">
<Metrics>
<Metric Name="Maintainability" Value="78" />
</Metrics>
</Module>
</Modules>
</Target>
</Targets>
</Report>
: 아래와 같은 는 XML 파일이 다소 보인다. 내가 그렇게 사용하고 코드는 다음과 같습니다 :
$testDLL = [regex]::matches($xmlfile[5], '<mod name=".*" ')[0].value -replace '<mod name="(.*)" ','$1'
#the above code line gets even the AssemblyVersion
$testAssembver = [regex]::matches($xmlfile[5], 'AssemblyVersion=".*" ')[0].value -replace 'AssemblyVersion=".*" ','$1'
내가 AssemblyVersion 필요하지 않습니다는 XML 코드에서 "testing.dll (XML에 모드의 이름)"에 연결될 수 할 수 있습니다.
testing.dll" AssemblyVersion=1.0.1000.112"
난 그냥 testing.dll 필요, 모든 것이 그 후 ommitted해야합니다
현재 내가 좋아하는 뭔가를 얻을.
도와주세요.
덕분에, 인 Ashish
감사의 말 JPBlanc. 그러나 -replace를 두 번 사용하거나 다른 것을 사용하는 방법이 있습니까? 나는 testing.dll을 얻고 있지만 함께 할 필요가있는 AsemblyVersion을 가지고있다. –
그리고 코드를 사용할 때 실제로 필드를 비워 둡니다. ( –
정확하게 XML 코드의 일부분을 추출 할 수 있습니까? 잘 만들었습니까? – JPBlanc