-
-
Save rewida17/28e705620d71bfd33404a68741dba941 to your computer and use it in GitHub Desktop.
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
# Beautify xml | |
# Ref: https://devblogs.microsoft.com/powershell/format-xml/ | |
function Format-XML ([xml]$xml) | |
{ | |
$StringWriter = New-Object System.IO.StringWriter | |
$XmlWriter = New-Object System.XMl.XmlTextWriter $StringWriter | |
$xmlWriter.Formatting = “indented” | |
$xmlWriter.Indentation = 4 | |
$xml.WriteContentTo($XmlWriter) | |
$XmlWriter.Flush() | |
$StringWriter.Flush() | |
$StringWriter.ToString() | |
} | |
# Get minified xml data | |
$header= @{"Accept" = "application/xml"} | |
$RawData = ( Invoke-WebRequest -UseBasicParsing -Uri "http://api.nbp.pl/api/exchangerates/tables/a" -Headers $header -Method Get ).content | |
Format-XML $RawData | Out-File -Encoding utf8 -FilePath C:\Dane\TabA.xml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment