PowerShell Quick Tip: Reading an XML file
Say you have an XML data like below.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<nodes> | |
<node> | |
<name>machine1</name> | |
<ip>1.2.3.4</ip> | |
</node> | |
</nodes> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$xmlFile = "C:\Users\u1\Documents\sample_nodes.xml" | |
$xmlDoc = [xml](Get-Content $xmlFile) | |
$xmlDoc.nodes.node.ip |
No comments:
Post a Comment