ShandM
ShandM

Reputation: 33

How to read XML generated by SVN in Powershell?

Am getting the following xml output through svn diff command.

<?xml version="1.0" encoding="UTF-8"?>
<diff>
<paths>
<path
   props="none"
   kind="file"
   item="modified">SDLC\Reports\Phase1 Analysis\report_phase1_code.xls</path>
</paths>
</diff>

I only need the complete path of the file i.e. "SDLC\Reports\Phase1 Analysis\report_phase1_code.xls" through powershell. However, because of the other attributes like props, kind, etc. present in the output, I am not getting the file path value.

Powershell code written is as follows:

[xml]$XmlDoc = Get-Content -Path output.xml

foreach( $user in $XmlDoc."diff".paths) 
{ 
    Write-Host $user.path
}

Any help on this topic would be appreciated. Thanks.

Upvotes: 1

Views: 156

Answers (1)

twglomski
twglomski

Reputation: 96

Should just have to do this:

foreach( $user in $XmlDoc."diff".paths) 
{ 
    Write-Host $user.path.'#text'
}

Upvotes: 1

Related Questions