I have several XML file that I need to read and set variable data from the node values.
example XML:
<Objs Version="1.1.0.1"
xmlns="http://schemas.microsoft.com/powershell/2004/04">
<Obj RefId="0">
<TN RefId="0">
<T>System.__ComObject#{86fd1ebe-92e2-40f3-9c03-e5f0ca55f8ab}</T>
<T>System.__ComObject</T>
<T>System.MarshalByRefObject</T>
<T>System.Object</T>
</TN>
<ToString>System.__ComObject</ToString>
<Props>
<S N="Name">copy1234</S>
</Props>
The script I'm writing must read the file and get the value "copy1234" into a variable. I suck, though, so it just returns NULL...
Get-ChildItem $ImportFolderPath -Filter *.xml | Foreach-Object {
$currentFile = $_.FullName
Write-Host "Processing file: $currentfile"
[xml]$ccXML = Get-content $currentFile
$ccName = Select-Xml -Path $currentfile -Xpath '//objs/obj/props/S[@N="Name"]'
Write-Host "Name of node: $ccName"
Select-Xml -Path $currentfile -Xpath '/ns:Objs/ns:Obj/ns:Props/ns:S[@N="Name"]' -Namespace @{ns='http://schemas.microsoft.com/powershell/2004/04'}Select-Xmlreturn to you.