Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Using Powershell to read XML

$
0
0

I have a weird XML doc where the data is contained in the node in placed.

An example. 

<computers>

<computerData ip-Dir="127.0.0.1" name ="eth01"/>

</computers>

What I want to do is get the IP address so I can edit it later. Here is the code I am using. 

$path = C:\temp\temp.xml

$xdoc = New-Object -TypeName XML
$xdoc.Load($path)
[xml]XMLConfig = Get-Content -path $path

$xdoc."computers"."computerData" | Select-Object -Property "ip-Dir"

This doesn't work though. Just gives me "ip-dir : "

Any thoughts?

Viewing all articles
Browse latest Browse all 21975

Trending Articles