In this article we will be seeing how to read an xml file in powershell 2010.
In this we will be creating a simple xml file and we will be reading the xml
file in the powershell.
Test.xml
<?
Xml
version="1.0"
encoding="utf-8"
?>
<customers>
<Name>Anand</Name>
<Id>123</Id>
<Age>23</Age>
<Location>Bangalore</Location>
</customers>
Get the content from the xml file:
[Xml]$xmldata=Get-Content
C:\Users\kpast\Desktop\Test.xml
![]()
Get all the nodes:
$xmldata.customers

Get a particular node:
$xmldata.customers.Name
![]()
Assign the xml value to a variable:
$variable=$xmldata.customers.Name
Result:
$variable
will be equal to Anand.

Gowtham RajamanickamPosted Apr 20, 2015, 3:17 PM
good
AshishPosted Oct 9, 2012, 9:26 AM
what if i have something like this in xml? <Name of person> instead of just <Name>