Monday, January 01, 2024

PowerShell Quick Tip: Reading an XML file

PowerShell Quick Tip: Reading an XML file

Say you have an XML data like below.
<?xml version="1.0"?>
<nodes>
<node>
<name>machine1</name>
<ip>1.2.3.4</ip>
</node>
</nodes>
To read the IP element in PowerShell, do:
$xmlFile = "C:\Users\u1\Documents\sample_nodes.xml"
$xmlDoc = [xml](Get-Content $xmlFile)
$xmlDoc.nodes.node.ip
view raw ReadXml.ps1 hosted with ❤ by GitHub
Tags: PowerShell, Xml

No comments:

How to configure nfs server on QNX 7.1

How to configure nfs server on QNX 7.1 Target: QNX 7.1 running on a VM (VMware Workstation or VirtualBox). It is assummed that the targets ...