XML2arr
function XML2arr{
param($xmlfile,$Value)
$erroractionpreference = 'SilentlyContinue'
$ici = (get-location).path
if(!$here){$here = $env:TEMP}
set-location $here
[xml]$xmlcontent = Get-Content -Path $xmlfile
[string]$header = $xmlcontent.DocumentElement.Name
$selectedSubheader = $xmlContent.$header.ChildNodes | Where-Object { $_.ChildNodes | Where-Object {$_.'#text' -eq $Value }}
if(!$selectedSubheader) {$selectedSubheader = $xmlContent.$header.ChildNodes | Where-Object {$_.ChildNodes | Where-Object { $_.'#text' -like "*$Value*" }}}
set-location $ici
return $selectedSubheader
}
$ArrXml = XML2arr -xmlfile <xml file fullname> -Value <one value in sub node>
/image%2F0881799%2F20140610%2Fob_a8c7fe_logo2.jpg)
Commenter cet article