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.
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: