Accessing XML

Learn how to access data inside XML in Python and Powershell.

Accessing XML as Objects

Once the XML document is parsed in PowerShell, it will be converted into objects which can be accessed using the dot operator ( . ) and can navigate nodes of the parsed XML tree, like in the following example.

Press + to interact
main.ps1
Test.xml
[xml]$xmldoc=Get-Content -Path '\usercode\Test.xml'
# returns Array of XML child nodes
$xmldoc.data.employee
# accessing a data value
$xmldoc.data.employee[0].first

Similarly, an ...